Hello
How can I set file permissions on my uploads folder? I am trying to figure out how users could upload pictures to the website, but it seems like the file permissions do not allow it and I cannot change it.
Hello
How can I set file permissions on my uploads folder? I am trying to figure out how users could upload pictures to the website, but it seems like the file permissions do not allow it and I cannot change it.
The chmod function is disabled a long ago, as it only creates problems, not solutions.
If you believe there’s a problem with the permissions, then let me tell you: there isn’t a problem with the permissions. So of course you won’t find a solution without a valid problem.
Please share your site url, code (without passwords if there’re any), and other informations as much as possible, so that we can better help you.
Hi Gwendarien,
Typical uploads do not require permission changes, meanwhile you can always process file uploads like you do using $_FILES. If you have trouble moving the file, then just do a simple copy like so:
$image = file_get_contents($_FILES['your form field name here']['tmp_name']);
file_put_contents('wherever you need to store this', $image);
While professionally speaking there are far more better ways to do this like stream copy, chunk reads and stuff, but those functions were unfortunately disabled on free hosting and this is the most simply method to go with for the time being.
You should also make clear to users that files >10mb won’t be saved due to free hosting limitations.
Cheers!
Ok I did manage get the upload to work with a bit of work and coding, but I am unable to post the images from the db to my website as an gallery. Not sure if it is another permission issue, but I tried so many ways I just ended up deleting all my attempts
Are you literally storing files into the database?
However, if you store it traditionally into an upload folder, you should be able to generate HTML img
tags that links back to each image in the upload folder.
You should be storing the filepath to the database instead of the string from file_get_contents()…
When you loop through the records to generate a gallery, always convert the relative path to a web link so that people are able to view that image at the correct path.
Cheers!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.