. Hello y'all, I'm trying to enable a user to pick a file, upload it, and then save the path to it in a database.
So far I have gotten the picture to "upload" in that it passes a validator and the path is sent to the database but other than that it is not working.
I can see in my FTP FileZilla that there is something in 'public/uploads/images' named 'cookie_monster_sir.png' (I'm using it as a test picture, don't judge me) BUT for some reason it's saved as a FILE FOLDER! lol. I have no idea how that happened. And then within the cookie_monster_sir.png folder there is another file that is titled 'php' and followed by numbers and letters. I'm guessing somewhere in the upload the file got messed up. I've tried uploading several times but I still just have the same file folder and more files that start with 'php' and are then followed by numbers and letters.
Any explanation or help on how to fix this and allow for functioning upload of a picture would be greatly appreciated! Thanks for your time!
Here is my view:
{{ Form::open(array('route'=>'order-create-post', 'name' => 'orderForm', 'id' => 'orderForm', 'files' => true)) }}
{{ Form::file('drawing_of_job') }}
<div class="row">
<input type = "submit" name = "submit" value="Create Order" id="submit" class="button radius expand"/>
</div>
{{ Form::close() }}
Controller:
public function postCreate(){
$validator = Validator::make(Input::all(),
array(
'drawing_of_job' => 'required|image',
)
);
if($validator->fails()){
return Redirect::route('order-create')
->withErrors($validator)
->withInput()
->with('global', 'There are fields with errors.');
} else {
/*Create Order*/
$drawing_of_job = Input::file('drawing_of_job');
$file_name = $drawing_of_job->getClientOriginalName();
$path_to_drawing = 'uploads/images/' . $file_name;
$drawing_of_job->move($path_to_drawing);
$order = Order::create(array(
'path_to_drawing' => $path_to_drawing,
));
if($order->save()){
return Redirect::route('home')
->with('global', 'Your order has been created.');
}
}
return Redirect::route('home')
->with('global', 'The order could not be created.');
}