Hi, This is my first website using PHP. Part of my website consists of letting the user upload files to the web server (images, pdf…). I am using the move_uploaded_file() function and it is working perfectly when I was testing my website on the web server installed on my local machine. But when I hosted the website it didn’t work. I discovered that I don’t have permission to access the temp folder on the server. Is there any way to make the user files uploaded directly to my hosting folder where I have full permission?
Thanks in advance.
Well, that depends. Your host probably allows you to change PHP directives in a .htaccess file, in which case you could then use a .htaccess in the root of your website alter the PHP directive that points to the directory PHP tries to save temp files/uploads/etc.
Otherwise, your host might allow you to place a php.ini file in a certain spot that PHP will then parse.
thank you bradgrafelma for your reply. yes i can change some php settings using the .htaccess file. but i don't think that it can change the upload_tmp_directory variable, it is because of the type of this variable 🙁 thanks again. but i am still searching for a solution.
you can set upload folder with
ini_set ("upload_tmp_dir", "/******/upload/");
But you have to create that folder, and have to set set a permission to that folder.
Change the ***** to your needs.
Maybe this helped 🙂
thisiskd is right - I didn't check first; upload_tmp_dir is a PHP_INI_SYSTEM variable (as explained in the manual). Sorry!
So, since you can't use a .htaccess file (and therefore ini_set() won't work either), contact your host and see what they say you are supposed to do.