PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and $_FILES['userfile']['name'] gives me the name of the file that I am uploading and I want to name it the same where it is getting uploaded .. so isnt it chmodding the file ??
Look again where and when you're calling chmod. You create a variable called $uploaddir, which, at least to me, signifies a directory. If you mean it to be a file, I'd change the name so that you don't confuse yourself. Then, you try to upload the file. What you don't do *after* you upload the file is set the permission on the file.
I'm guessing that $up is set, so the script echoes "File uploaded" but you can't get access to the file? If so, put the chmod statement in after the call to move_uploaded_file.
so now tell me if you are telling to chmod for the file how do I do that, as in how will get only the file name..
I tried chmodding after move_uploaded_file() but it gives me a warning message : chmod(): No such file or directory in /home/httpd/htdocs/gbcb/upload_app_files.php on line 16
Something to keep in mind, this is at least true for me..
If you are using an upload script, the file you upload is created (under Linux/Unix) as the owner that the web server runs under. And if you are a different user on the system, then you are not the owner of the uploaded file, even if it is in your home directory.
Ie. If Apache runs under user nobody in group nobody, then PHP will create an uploaded file with the owner nobody and group nobody. You see. Same thing if your web servers runs under user httpd or whatever user/group it is. PHP will create files that way too.
what kind of OS ? (Unix,Windows,Sol....) ???
what kind off permissions does the executing script file has ???
(the executing script file is the file where from your script is running)
when the script file hasn't got the right permissions set . it can not do the job.
I tried doing it but it still gives me the error !! Warning: chmod(): No such file or directory in /home/httpd/htdocs/gbcb/upload_app_files.php on line 16
Pyrite : I think what you told might be happening with me. The file is not owned by me,the owner is the server where it is running the file. So do you think that might be the problem here since it doesnt allow me to change permissions on some other's owned files ??
Judas : Well I am on Windows and the server is on Unix. ie I am coding from windows and running on unix server.
but still not working. now for doing ftp or telnet is it required that I should be the owner of the file, coz in my case the owner of the file is apache, the server where it is running the file.