I have form for uploading images in Laravel 5.3. These images are uploaded into directory (project_root/public/uploads/images/). When I turn on the URL example.com/public/uploads/images/filename.png (eg) or example.com/uploads/images/filename.png, I only get 404 NotFoundHttpException.
The images, of course, there are. But I cant dump the contents of a public folder over URL.
Can you help me please? Thanks!
The 'correct' way is to use your Storage facade and store it in the storage/public folder.
This folder is like your public folder, but you can apply all kinds of logic that you don't want to put in your public folder.
Without knowing more about how you are 'dumping' the contents of your public folder (with code or just a get request?) or how you are saving your files, i can't tell you what the problem is. It could be you have made a custom .htaccess rule?
Related
I have a web application and I want to save data in a file instead of in the database.
My doubt is, where I should save the file? If I save it under the public directory, I could refer them with the assets to make the correct URL, but in the public directory, any person could see the file writing the complete URL. This shouldn't be because de data is reserved.
I think about the var directory, but I couldn't use the assets to make the correct URL to get or manage the files.
Where I should save the files and how I get/manage them?
If the data-file is local and hosted on the server's file system, the most logical place to store something like that would be the var directory. Although nothing stops you from creating your own "var-like" directory and naming any way you like it. E.g. data. But I would follow the conventions and create var/data, easier for everyone.
That you can't use the asset() function is irrelevant, because a data-file is not a web asset, but an infrastructure concern.
A file like this should not have a URL at all, but you would only access it through it's file system path.
I have created an upload folder at the same level of app and storing uploaded files there. Now I need to access those file via browser so need to have an http:// based address.
First, am I doing right? What are Laravel 5.1's recommendation? Where should files be stored? If no recommendation then how do I get ULRs?
Store the files within your public folder create uploads folder and then you can simply access from there using asset() function like as
asset("uploads/your_file")
You can use Request::root() to get the root URL of your website and then simply use Request::root()."/uploads/your_file"
How can I restrict PHP files from getting executed outside the application folder?
I am using CodeIgniter and I have heard it somewhere that this thing is possible in CodeIgniter.
Temporary, I have added request in htacess which will surpass each request from index file and will result in not found.
Add public folder, move index.php into it, inside index.php change application and system folder settings to ../application and ../system respectively. Point domain to public folder.
I'm trying to add the ability to upload a photo via a Laravel form. However, I seem to be a little bit outside of the normal use cases for getting it configured.
My laravel directory is actually outside of my main web directory, and for certain URI's, it uses an Apache mod_alias to redirect it to use the Laravel Framework. All of my css, js and images exist in the main web directory, and all of my laravel files and directory exist in its own separate directory. With that said, the location I want to be able to upload photos to is
/html/images/profile-photos
while my laravel app lives in
/laravel/...
In the controller for my form, I have
$photo = Input::file('photo');
if ($photo->isValid()) {
$destinationPath = '/html/images/profile-photos/';
$filename = $user->id; //There might be a separate error in not including the file extension here?
$photo->move($destinationPath, $filename);
}
But when I attempt to upload an image with the form, I get the error
Unable to create the "/html/images/profile-photos/" directory
By the looks of it, it appears it might not be going to the actual /html directory, but might still be stuck in the /laravel one. Is there a way to go about getting it stored in the intended location?
Apologies. As soon as I posted this question, I realized my root directory was actually one step back. It had to be
'/root/html/images/profile-pictures'
As soon as you say it's broken, it fixes itself...
i have a URL that looks like this
......index.php?option=com_jumi&fileid=8&Itemid=34
i know that i can view the source of the file just by view source from the browser, but since i have FTP permission for the site, i would like to be able to edit the file.
but i dont know which file to edit!
how do i find out which file is this link going to so that i can access it through ftp?
It should be here:
Root Joomla Folder -> Components -> com_jumi
Now inside the com_jumi folder, it depends which file you want to edit, for example there you will find the file for current pages looks (View), a file with database queries (Model) and a main logic file called controller. You have to decide which file you want to edit.
Note: inside the com_jumi folder, the files can be inside other folders too, you will have to find out which file you want to edit.