Laravel4:文件上传

时间:2014-04-22 19:01:03

标签: php file-upload laravel laravel-4

我有这段代码:

        $file = Input::file('image');
        $destinationPath    = base_path().'public/upload/slider/'; // The destination were you store the image.
        $filename           = $file->getClientOriginalName(); // Original file name that the end user used for it.
        $mime_type          = $file->getMimeType(); // Gets this example image/png
        $extension          = $file->getClientOriginalExtension(); // The original extension that the user used example .jpg or .png.
        $upload_success     = $file->move($destinationPath, $filename); // Now we move the file to its new home.
        // This is were you would store the image path in a table

我的上传文件夹中的文件名是: public / upload / slider / folder.gif public / upload / slider / footer_left_line.jpg public / upload / slider / phpJtC4Jj public / upload / slider / folder_o.gif public / upload / slider / mail.gif public / upload / slider / post_photo_icon.png  你怎么看待这个问题?

1 个答案:

答案 0 :(得分:1)

替换以下行:

$destinationPath    = base_path().'public/upload/slider/';

有了这个:

$destinationPath    = 'upload/slider';

它会在public/upload/slider文件夹中上传文件。您不需要在base_path()中使用public$destinationPath

相关问题