Jump to content

Recommended Posts

Is there any way to temporarily change the permissions on a newly-created folder on a server? I've created a series of folders for photo galleries, but when I want to upload the files it tells me I can't.

Warning: move_uploaded_file(gallery1/telusawallpaper.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in ...

 

I know I could go onto the server and change the permissions manually, but ideally I would like the user to be able to upload photos themselves.

 

Current code is:

$gallery="gallery".$_POST['galleryID'];

$target_path = "$gallery/";

$photo = $_FILES['uploadedfile']['name'];

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

  $result = "Photo has been successfully uploaded into the $gallery folder";

} else {

    $result = "There has been an error. Try again later";

}

Link to comment
https://forums.phpfreaks.com/topic/131602-uploading-files/
Share on other sites

Tried this:

$gallery="gallery".$_POST['galleryID'];

$target_path = "$gallery/";

chmod("/$gallery", 777);

Where $gallery will be something like gallery1 or gallery2, etc.

 

Got this error though: Warning: chmod() [function.chmod]: No such file or directory in...

The gallery definitely exists, so I think the problem is having a variable in the middle of the chmod parameters. How would I fix this?

Link to comment
https://forums.phpfreaks.com/topic/131602-uploading-files/#findComment-683501
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.