Jump to content

Recommended Posts

Posted

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?

Posted

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.

Posted

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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...