Thanks to visit codestin.com
Credit goes to github.com

Skip to content

JosefMor/laravel-media-upload

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple and Easy AJAX Media Upload for Laravel

Build Status Total Downloads Latest Stable Version License

This is a package to make AJAX upload process easy and simple! Enhance your customer experience and improve your system performance.

###SEE DEMO

Requirements

Installation

Require this package with composer:

composer require triasrahman/media-upload

After updating composer, add the ServiceProvider to the providers array in config/app.php

'providers' => [
	//	...
	'Triasrahman\MediaUpload\MediaUploadServiceProvider',
]

Copy the package config to your local config with the publish command:

php artisan vendor:publish

Usage

Your HTML form

<input type="file" name="file">
<img clas="preview" src="">

Using jQuery AJAX

$('input[name=file]').change(function()
{	
	// AJAX Request
	$.post( '/media-upload', {file: $(this).val()} )
		.done(function( data )
		{
			if(data.error)
			{
				// Log the error
				console.log(error);
			}
			else
			{
				// Change the image attribute
				$( 'img.preview' ).attr( 'src', data.path );
			}
		});
});

Configurations

Edit media-upload.php for more configurations.

/*
 |--------------------------------------------------------------------------
 | Upload Types
 |--------------------------------------------------------------------------
 |
 | It's the flexibility of this package. You can define the type of upload
 | file methods. For example, you want to upload for profile picture,
 | article post, background, etc. Here is 
 |
 */

'types' => [
	// ... put your custom type ...

	'profile' => [
		'middleware' => 'auth',
		'format' => 'image',
		'image' => [
			'fit' => [400, 400],
			'thumbs' => [
				'small' => [50, 50],
				'medium' => [100, 100],
			]
		],
		'save_original' => true,
	],

	'profile-cover' => [
		'middleware' => 'auth',
		'format' => 'image',
		'image' => [
			'fit' => [1200, 400],
		],
		'multiple' => false,
	],

	'media' => [
		'middleware' => 'auth',
		'format' => 'image|video|audio',
		'image' => [
			'thumbs' => [
				'small' => [50, 50],
				'medium' => [100, 100],
			]
		],
		'multiple' => true,
	],

],   

Front-end Integration

Coming Soon

License

Laravel Media Upload is licensed under the MIT License.

Copyright 2015 Trias Nur Rahman

About

Simple and easy AJAX media upload for Laravel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%