php - Can't upload images to a public directory in laravel -


I am trying to upload images in a Laravel app, which will then need to be displayed publicly. However, I think that only the application will be able to upload to a folder within the root. Any attempt to upload to the public directory throws the following error:

  secure function getTargetFile ($ directory, $ name = null) {if (! Is_dir ($ directory)) {if = == @ Mkdir ($ directory, 0777, true)) {new file expansion (sprinif ("% s" directory, unable to create $ directory));  

I'm saying that Laravel has to stop me from uploading any files that are publicly accessible. I really like this, however, I'm out of the public directory How can I link to images / I tried to get out of the public folder, but justly, which was not working.

Alternatively, whatever allows me to upload directly to public folder will be great.

If it helps, then it is my controller method that puts the file in the public folder:

$ thumbnail_file = input :: file ('thumbnail') ; $ Destination path = '/ upload /' str_random (8); $ Thumbnail_filename = $ thumbnail_file-> GetClientOriginalName (); $ UploadSuccess = Input :: File ('thumbnail_arl') - & gt; Move ($ destinationpath, $ thumbnail_filename);

Your destination path should be:

  $ DestinationPath = public_path (sprintf ("\\ upload \\% s \\", str_random (8)));  

Comments