Jump to content

Uploading files


padams

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

Archived

This topic is now archived and is closed to further replies.

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