Closed ghost closed 11 years ago
Do you have the correct enctype on your form?
Please don't create issues if you are not sure if it is a bug, post on forums instead.
Yes I have enctype="multipart/form-data" set on the form.
What type of file are you trying to upload?
From my tests
My view
<form method="post" enctype="multipart/form-data">
<p><input type="file" name="test"></p>
<p><input type="submit"></p>
</form>
My POST Route
var_dump(Input::file());
var_dump(Input::file('test'));
Returns
array (size=1)
'test' =>
object(Symfony\Component\HttpFoundation\File\UploadedFile)[9]
private 'test' => boolean false
private 'originalName' => string '135079122234.gif' (length=16)
private 'mimeType' => string 'application/octet-stream' (length=24)
private 'size' => int 0
private 'error' => int 1
object(Symfony\Component\HttpFoundation\File\UploadedFile)[9]
private 'test' => boolean false
private 'originalName' => string '135079122234.gif' (length=16)
private 'mimeType' => string 'application/octet-stream' (length=24)
private 'size' => int 0
private 'error' => int 1
I tested with JPG, PNG, GIF, TXT and PDF, all showed up correctly for me
I'm trying to upload a JPG. I tried mutiple file types everything is returning null.
Form:
form action="image/add" method="post" enctype="multipart/form-data" input type="file" name="photo" input type="submit" value="Upload"
( I stripped the tags open/close tags cause it kept showing up blank )
Route:
var_dump(Input::file()); var_dump(Input::file('photo'));
Result:
array empty null
Just try the native PHP superglobal $_FILES
to see if this is a Laravel issue, as I don't think so.
$_FILES is returning null also so cant be Laravel. My mistake for thinking this was related to Laravel!
I am having this same issue very strange.
Input::get('photo'); // returns []
$_FILES['photo'] // I get the object
Not sure why this is happening, I dug down and see that Symfony2 is the Request and looks like it should be set. Any thoughts?
I have the same issue as vanderlin
Please, considere check "upload_max_filesize" php php enviroment
@vanderlin, @Cederman You should use Input::file('photo')
to get the uploaded file object.
If you use Input::get(...)
on a file upload you should get the filename I believe...
=> Just for google/search... know this is history :)
I have same problem.I read all comments about the bug.Also, I considered to upload_max_size and post_max_size configurations.still it's not working again.
I have same problem !
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);
Don't work, it give me a file with this inside :
/private/var/tmp/phpNz8cZJ
And I have the same probleme with this code ->
move_uploaded_file(Input::file("file"), "uploads/image".$id.".jpg");
The file is broken...
But when i acces with no profixy, it's working ! I do my test like this ->
i got an error while i am using summernote and post data into my controller
[files] => Symfony\Component\HttpFoundation\File\UploadedFile Object ( [test:Symfony\Component\HttpFoundation\File\UploadedFile:private] => [originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 38h_900.jpg [mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => image/jpeg [size:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 170689 [error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0 [pathName:SplFileInfo:private] => C:\xampp\tmp\php242E.tmp [fileName:SplFileInfo:private] => php242E.tmp ) )
Please, considere check "upload_max_filesize" php php enviroment
This works with me. Remember restart php-fpm
$ php -i | grep "Loaded Configuration File"
$ code /usr/local/etc/php/7.4/php.ini
## Change line upload_max_filesize
$ php -i | grep "upload_max_filesize" ## Verify
brew services restart php@7.4
I'm trying to upload a file and the Input::file keeps returning null.
Example form
$file = Input::file() returns null. $file = Input::file('image') returns null. $file = Input::all() returns null.