asherinho Posted December 15, 2008 Share Posted December 15, 2008 Whats up guys? I am having a problem with the path to put the folder for uploaded files in the control panel.Below is the view of the directory tree,you can see the position of the uploads folder.Is that the correct place to put that folder? I have been getting this warnig Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/uploads/ASHRY.gif) is not within the allowed path(s): (/home/mtibwa:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/mtibwa/public_html/upload.php on line 12 [/img] [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 15, 2008 Share Posted December 15, 2008 /uploads/ASHRY.gif A leading slash on a file system path refers to the root of the current hard disk. Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/#findComment-716178 Share on other sites More sharing options...
asherinho Posted December 15, 2008 Author Share Posted December 15, 2008 FMaBiSmAd are you suggesting I should use "uploads/" as a path to where the file is uploaded? I tried it but still it doesn't work.Below is the code for the page which uploads the file <? $file_dir = "uploads/"; if($_FILES['fileupload']['size'] <= 81200){ foreach($_FILES as $file_name => $file_array) { print "path: ".$file_array['tmp_name']."<br>\n"; print "name: ".$file_array['name']."<br>\n"; print "type: ".$file_array['type']."<br>\n"; print "size: ".$file_array['size']."<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], "$file_dir".$file_array['name']) or die ("Couldn't copy"); print "file was uploaded!<br><br>"; } } }else{ print "large size!<br><br>";} ?> Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/#findComment-716204 Share on other sites More sharing options...
PFMaBiSmAd Posted December 15, 2008 Share Posted December 15, 2008 Just uploads/ will be relative to the currently running script. If we assume you put the uploads folder where it is because you wanted it there, you must form a path to where it is at /home/mtibwa/uploads/. You could hard code this, but it is better to form it at runtime using $_SERVER['DOCUMENT_ROOT'] so that your script will continue to work no matter where it is at as long as the folder structure is maintained. This should work - $file_dir = $_SERVER['DOCUMENT_ROOT'] . '/../uploads/'; Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/#findComment-716227 Share on other sites More sharing options...
asherinho Posted December 16, 2008 Author Share Posted December 16, 2008 I tried it taht way. <? $file_dir = $_SERVER['DOCUMENT_ROOT'] . '/../uploads/'; if($_FILES['fileupload']['size'] <= 81200){ foreach($_FILES as $file_name => $file_array) { print "path: ".$file_array['tmp_name']."<br>\n"; print "name: ".$file_array['name']."<br>\n"; print "type: ".$file_array['type']."<br>\n"; print "size: ".$file_array['size']."<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], "$file_dir".$file_array['name']) or die ("Couldn't copy"); print "file was uploaded!<br><br>"; } } }else{ print "large size!<br><br>";} ?> It doesn't work yet.I am getting the following warnings Warning: move_uploaded_file(/home/mtibwa/public_html/../uploads/ASHRY.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/mtibwa/public_html/upload.php on line 12 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpSoClj8' to '/home/mtibwa/public_html/../uploads/ASHRY.gif' in /home/mtibwa/public_html/upload.php on line 12 Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/#findComment-716464 Share on other sites More sharing options...
PFMaBiSmAd Posted December 16, 2008 Share Posted December 16, 2008 Please at least read the error messages and attempt to solve what they are telling you is wrong - Permission denied The permissions on the uploads folder are not set correctly. Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/#findComment-716493 Share on other sites More sharing options...
suma237 Posted December 16, 2008 Share Posted December 16, 2008 Do you check the upload folder permission?.tick all permissions. Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/#findComment-716510 Share on other sites More sharing options...
waynew Posted December 16, 2008 Share Posted December 16, 2008 777 that biatch. Link to comment https://forums.phpfreaks.com/topic/137108-file-upload-problemhelp-please/#findComment-716526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.