I'm using fineuploader as a delivery vehicle for a file upload in my application.
When the upload request is submitted it returns the following errors via JSON response:
Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
The file "/tmp/phptHwPd5" does not exist
/srv/www/laravel/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php, line 115
According to the first error, the temp file seems to be getting lost after the upload. I have an existing CodeIgniter application using fineuploader on the same environment (CENT OS 6) so I know file uploads are functional. I tried changing folder permissions but that did not help. It's able to capture the file object from Input, but after that things break down.
File handler code:
if (Input::hasFile('qqfile')) {
$file = Input::file('qqfile');
// move to media storage
$dest = 'images/tmp';
$file->move($dest);
// add record
$media = Media::create(array(
'name' => $file->getClientOriginalName(),
'location' => $dest,
'mime' => $file->getMimeType(),
'size' => $file->getSize()
));
}
re arrange the code like this
// move to media storage
$dest = 'images/tmp';
// add record
$media = Media::create(array(
'name' => $file->getClientOriginalName(),
'location' => $dest,
'mime' => $file->getMimeType(),
'size' => $file->getSize()
));
$file->move($dest);
Well, that worked, but I have no idea why...
well you have found a bug on Symfony\Component\HttpFoundation\File
class implementation
see, this class extends the native class SplFileInfo
, when you instantiate this class, the instance is associate to a file path location, so if you move this file, SplFileInfo
will still pointing to the old file path, so any next method call will fail
still, the solution of this is error is very complicated because you need to replace the current instance, $this
, to a new one
Probably doing this would solve that too:
$file = $file->move($dest);
Interesting. Thanks for the info guys.
It could also be related to the file size.
https://github.com/1up-lab/OneupUploaderBundle/issues/44
I personally solved the same issue increasing the post_max_size
and upload_max_size
values to 32M.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community