ashok Posted October 26, 2004 Posted October 26, 2004 Hi, I am writing a site where a site admin can upload files. I think I am running into directioy permission issues. I want the site admin to upload files into its images directory. admin authentication is saved in mysql database. Is there a way that I have it uploaded into the "images" subdirectory? Here's the code excerpt: .... $upfile = get_cwd() . '/images/' . $userfile_name; .... if (is_uploaded_file($userfile)) { if (!move_uploaded_file($userfile, $upfile)) { echo 'Problem: Could not move file to destination directory'; return(''); } } This is not working. But, if I change $upfile to /tmp. it works! This leads me to believe that the user does not have write permission to the images directory. Can I change dir permissions? Quote
borfast Posted October 26, 2004 Posted October 26, 2004 Yes, if you change the permissions on the folder to allow everyone to write to it, it should work. Do keep in mind that this may represent some danger, as you are allowing any user in the server to write to that directory. Quote
ashok Posted October 26, 2004 Author Posted October 26, 2004 How do I change directory permissions? Do I have access to do this or do I need to open a support ticket? I understand there is a danger in opening a directory for anyone. How do others do this if they need to allow users to upload files. In my case, I want the site administrator to add items to shopping cart and upload item images. Quote
borfast Posted October 26, 2004 Posted October 26, 2004 You can change the directory permissions via the cPanel's file manager or using an FTP client. I strongly suggest the FTP client. There's no other way to do it (well, there is but it's much more complicated). But don't worry too much about it, it's not that serious, anyway. Everyone uses it in shared hosting environments when they need to upload files through scripts. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.