triasrahman/media-upload

This package is abandoned and no longer maintained. No replacement package was suggested.

Simple and easy AJAX media upload for Laravel

v1.0.3 2015-06-12 19:12 UTC

This package is not auto-updated.

Last update: 2020-08-21 20:25:35 UTC


README

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