padams Posted November 6, 2008 Share Posted November 6, 2008 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 More sharing options...
Adam Posted November 6, 2008 Share Posted November 6, 2008 Give chmod a go... http://uk.php.net/chmod Link to comment https://forums.phpfreaks.com/topic/131602-uploading-files/#findComment-683499 Share on other sites More sharing options...
padams Posted November 6, 2008 Author Share Posted November 6, 2008 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 More sharing options...
padams Posted November 6, 2008 Author Share Posted November 6, 2008 The other approach I considered was changing the permissions when I created the folder. So I used mkdir("flashgallery/$galleryName", 0777); However, the permissions reverted back to 755 as soon as the folder was created. Is there any way around this? Link to comment https://forums.phpfreaks.com/topic/131602-uploading-files/#findComment-683533 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.