2014-04-22 79 views
0

我有這樣的代碼:Laravel4:文件上傳

 $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 

和文件名在我的文件夾上傳是: 公共/上傳/滑塊/的Folder.gif公共/上傳/滑塊/ footer_left_line.jpg公共/上傳/ slider/phpJtC4Jj public/upload/slider/folder_o.gif public/upload/slider/mail.gif public/upload/slider/post_photo_icon.png 您對這個問題有什麼看法?

+0

請您詳細描述問題嗎? _(從一開始,看起來這只是一個帖子,末尾有可能是無關的問題......)_ – summea

回答

1

替換以下行:

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

有了這個:

$destinationPath = 'upload/slider'; 

它會在你public/upload/slider文件夾上傳文件。您不需要在$destinationPath中使用base_path()public

+1

謝謝,它的工作原理 – r3v

+0

不用客氣,你應該接受答案,點擊我的箭頭底部回答:-) –