I am currently trying to create a file upload script for use with my site. I have everything working with regards to actually getting the file up onto the server and into the right directory etc, but every time I upload a file, it's set so that not being a superuser on the server, I can't overwrite it or delete it.
I've chmodded the destination directory as 777 but that didn't work and using PHP's chmod command after the file is uploaded doesn't work as it is already set so that only a superuser can modify it, so the script dies.
Any ideas on how to get around this?
Well when you upload a fiel to your server the user that runs the web server is the owner f the script, so you should write a script to delete the uploaded files, because it runs as the user that owns the uploaded files. does that make sense?
ie - use <? unlink($filename);?> and 777 is bad ...
I have the exact same problem... only the files are owned by "www" and i canīt delete, chmode, or even read them!! :bawling:
When i try to use them (link them in a webpage) itīs just like they are not there.
I canīt even dowload them! When i try to download from Cuteftp, it says file does not exists.
how to fix this?, is there a way to change the owner of the file (within a php script)?
Or at least a way of use them (link them from a webpage) (since i know i can write a script to delete them).
Thanks in advance
php runs as nobody on the server:( so when you upload a file its owner is nobody, not you. You can try to run your php upload script as cgi, just place line below on the first line of your script and save as upload.cgi and set chmod 755, hope your host supports it.
I know that if your host has safe_mode ON then you have to run the upload script as a CGI because otherwise your script will not be able to access the uploaded file because it is sitting in the temp directory which is outside your document root (www) directory.
Im having the same problem, what I'm wondering is- is there a way to chmod in php so that at least my scripts could alter a file. What I'm having trouble with is my script uploads a file (an image) and then it tries to use imagemagick to change the image but the permission settings wont let it.