iiCe89's avatar

File Upload issue

i was following tutorial to add file upload to website however it seemed to stop dead lol ?

i created the Fileuploadcontroller

class FileuploadingController extends Controller { // create function for our upload page public function index(){ return view('uploadfile'); } // create new function for show uploaded page public function showfileupload(Request $request){ $file = $request -> file('image'); // show the file name echo 'File Name : '.$file->getClientOriginalName(); echo '';

  // show file extensions
  echo 'File Extensions : '.$file->getClientOriginalExtension();
  echo '<br>';

  // show file path
  echo 'File Path : '.$file->getRealPath();
  echo '<br>';

  // show file size
  echo 'File Size : '.$file->getSize();
  echo '<br>';

  // show file mime type
  echo 'File Mime Type : '.$file->getMimeType();
  echo '<br>';

  // move uploaded File
  $destinationPath = 'uploads';
  $file->move($destinationPath,$file->getClientOriginalName());
}

}

and included the Routes

Route::get('/uploadfile', 'FileuploadingController@index'); Route::post('/uploadfile', 'FileuploadingController@showfileupload');

this all works when viewing i can select file & upload but then i am left with this displayed on browser

File Name : testdoc.rtf File Extensions : rtf File Path : /private/var/folders/pv/h8n27hp15vxdrlkmyjxqtb_80000gn/T/phpBrVAUb File Size : 420 File Mime Type : text/rtf

Unsure of what is going on as i obviously cant follow rest of tutorial as there isn't anything left

0 likes
2 replies
ejdelmonico's avatar
Level 53

Try testing with a plain text (txt) file. It could be a MIME type issue. Or, you could try using accept=".rtf, text/rtf, application/rtf, text/richtext" in the input tag.

1 like

Please or to participate in this conversation.