I am trying to upload some photos and handle this using assembly in Laravel functions. But I canโt understand for my whole life how to do this properly. I really could download something, but I was having problems. This is the code that I have right now:
If you look at the documentation and find this function: $file = Input::file('photo'); I used this function and the contents of $file becomes an instance of Symfony\Component\HttpFoundation\File\UploadedFile , which, as the documentation tells us, extends the PHP class SplFileInfo and provides many methods for interacting with the file. " Http://laravel.com/ docs / 4.2 / requests # files
Then I used this function Input::file('photo')->move($destinationPath); , which should, but the file is in the right folder on the server. And that happened. But now there is a problem. Now all downloaded files have a file name, for example phpgoJnLc , and without the extension.
I looked at the functions available from SplFileInfo and tried getExtension , which give me an empty string and getFilename , which also gives me something like phpgoJnLc .
Then I looked around the internet and found several pieces of code from Laravel 3 where they did something like this:
$filename = Str::random(20) .'.'. File::extension(Input::file('photo.name'));
But the result of this gives me the result only from Str::random(20) , followed by a dot. Again, the file extension.
So what am I doing wrong? How to upload a file using Laravel 4?
Crinsane
source share