multiple upload laravel with the same name

Ahmed Naguib

I've created new code for editor to upload image by laravel. I use a laravel method with a loop, so if I selecetd 2 images it's upload the first one twice.

How can I solve it?

I think I need to clear Input :)

public function ajax_editor_image() {
    if (Input::file()) {
        $image = Input::file('image');
        $filename = time() . '.' . $image->getClientOriginalExtension();
        $path = public_path('uploads/' . $filename);
        // Image::make($image->getRealPath())->resize(200, 200)->save($path);
        Input::file('image')->move('uploads/', $filename);
        $base_url = URL::to('/');;
        return response()->json([
            'data' => [
                "id"          => "",
                "title"       => null,
                "description" => null,
                "datetime"    => 1462962209,
                "type"        => "image/jpeg",
                "animated"    => false,
                "width"       => 720,
                "height"      => 960,
                "size"        => 108627,
                "views"       => 0,
                "bandwidth"   => 0,
                "vote"        => null,
                "favorite"    => false,
                "nsfw"        => null,
                "section"     => null,
                "account_url" => null,
                "account_id"  => 0,
                "in_gallery"  => false,
                "deletehash"  => "NYoWYJZkpdFyahb",
                "name"        => "",
                "link"        => $base_url . '/uploads/' . $filename,
                "success"     => true,
                "status"      => 200
            ]
        ]);
    }
}
Vikash

Try this name as image name

$filename  = time() .'-'.$image->getClientOriginalName().'.' . $image->getClientOriginalExtension();

I also had the same problem . sometimes it will upload at same time and your file name would be same. so by adding name to the image also it would be definitely unique.

I think it will help.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Laravel - multiple controllers with same name

From Dev

Change the name of multiple file upload in laravel

From Dev

Laravel query with joins, same name in multiple tables

From Dev

Upload multiple documents with same field name using form submit

From Dev

Converting multiple same name into one single name in laravel

From Dev

Laravel file upload name is incorrect

From Dev

Multiple parameters by the same name

From Dev

Multiple functions with the same name

From Dev

Multiple divs with same name

From Dev

Multiple inputs with same name

From Java

How to upload multiple images in Laravel using AWS bucket, and ignore if same image uploaded?

From Dev

Multiple Image Upload in Laravel 5.2

From Dev

Multiple upload using Laravel Storage

From Dev

Laravel | Multiple file upload not working

From Dev

Flume configuration to upload files with same name

From Dev

Upload file, check for same file name

From Dev

Laravel unique name but if the id is the same

From Dev

Multiple EJB beans with same name

From Dev

Multiple Inheritance: same variable name

From Dev

Multiple external packages with same name

From Dev

Multiple actions with same action name

From Dev

Behave, multiple steps with same name

From Dev

Saving multiple files with same name

From Dev

Submitting multiple inputs with same name

From Dev

Parse multiple headers with same name

From Dev

Multiple sling configs with same name

From Dev

Getting multiple subpatterns with the same name

From Dev

Multiple WiFi Networks with the Same Name

From Dev

post multiple fields with same name