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