You are not logged in.

Important Note: This forum is being archived and will be completely locked down on the 7th of February. The new forum can be found at http://laravel.io.

Announcement

    Laravel 4 Advanced Architecture: Book Now On Sale

#1 2012-05-24 06:45:54

evilgenius
Artisan
Registered: 2012-05-10
Posts: 9

Multiple File Upload

Does anyone know how to validate multiple file uploads?

Offline

#2 2012-05-25 12:08:18

redbaron76
Artisan
From: Italy
Registered: 2011-10-17
Posts: 126
Website

Re: Multiple File Upload

In your start.php register a new validation rule like this:
(I use this to check if file already exists)

Validator::register('unique_file', function($attribute, $value, $parameters)
{
    
    //CHECK UNIQUENESS OF FILE NAME ON DISK

    $file_name = $value;
    $path = $parameters[0];

    return !file_exists(path('public') . $path . $file_name);

});

Then use it in your route to validate file

$rules = array(
	'file'  => 'unique_file:'.$upload_path,
);

Hope it could help you.

Offline

#3 2012-09-27 12:00:17

reineskye25
Artisan
From: Phillipines
Registered: 2012-09-10
Posts: 214
Website

Re: Multiple File Upload

@redbaron76 --- Hi, can that validate an array of files? Like my problem here -- http://forums.laravel.com/viewtopic.php?id=2715 ? Thanks in advance.


http://laravelsnippets.com/ - Laravel snippets website | A repository of useful code snippets for Laravel PHP framework. Submit, grab and share!
http://john.mayonvolcanosoftware.com/ - My personal website
http://www.mayonvolcanosoftware.com/ - Mayon Volcano Software Ltd.
https://twitter.com/johnkevinmbasco - Twitter

Offline

Board footer

Powered by FluxBB

');