phpSensei Posted September 29, 2007 Share Posted September 29, 2007 Hi, its my first time getting a real domain, and everytime a user uploads a file it gets a permission denied message. Warning: move_uploaded_file(uploads/x7B88X_X_00_X_XXXXS_hangman_fk.swf) [function.move-uploaded-file]: failed to open stream: Permission denied in /mounted-storage/home45c/sub002/sc33159-IXOG/flash-portal.org/fp-upload/1/do_upload.php on line 128 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phppJshkA' to 'uploads/x7B88X_X_00_X_XXXXS_hangman_fk.swf' in /mounted-storage/home45c/sub002/sc33159-IXOG/flash-portal.org/fp-upload/1/do_upload.php on line 128 <?php if(isset($_POST['Upload'])){ /* Form Fields */ $name = trim($_POST['name']); $resize = $_POST['resize']; $h = trim($_POST['h']); $w = trim($_POST['w']); $tos = $_POST['tos']; if(($h > 1000)||($w > 1000)){ header("Location: http://flash-portal.org/fp-upload/1/?notice=009&error=yes"); // Invalid File die(); } /* File Handler */ $filename = $_FILES['swf']['name']; // file name $filesize = $_FILES['swf']['size']; // file size $filetype = $_FILES['swf']['type']; // file tpye $filetemp = $_FILES['swf']['tmp_name']; // file temp $file_error = $_FILES['swf']['error']; // errors $path = "files/"; // Upload directory $target_path = $path . basename( $_FILES['swf']['name']); // Full path directory /* Form Handler */ if(empty($filename)){ header("Location: http://flash-portal.org/fp-upload/1/?notice=003"); // Empty Field die(); } if((!empty($h))||(!empty($w))){ if(!is_numeric($h)){ header("Location: http://flash-portal.org/fp-upload/1/?notice=007&error=yes"); // Invalid DATA die(); } elseif(!is_numeric($w)){ header("Location: http://flash-portal.org/fp-upload/1/?notice=008"); // Invalid DATA die(); } } else { $h = 550; $w = 450; } if(!isset($tos)){ header("Location: http://flash-portal.org/fp-upload/1/?notice=000"); // Empty field die(); } elseif($filetype != "application/x-shockwave-flash"){ header("Location: http://flash-portal.org/fp-upload/1/?notice=005"); // Invalid File die(); } elseif($filesize > 10000000 ){ header("Location: http://flash-portal.org/fp-upload/1/?notice=006"); // File too large die(); } else { $array1=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); shuffle($array1); /////////////////////// $array2=array("0","1","2","3","4","5","6","7","8","9"); shuffle($array2); /////////////////////// $array3=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); shuffle($array3); /////////////////////// $array4=array("0","1","2","3","4","5","6","7","8","9"); shuffle($array4); /////////////////////// $array5=array("_","X","_","X"); shuffle($array5); /////////////////////// $array6=array("0","1","2","3","4","5","6","7","8","9"); shuffle($array6); /////////////////////// $array7=array("XX_x_x-x_XXXX","XXX_x_x_X","XXXXXXXX_x__xxxx_XXX","X_00_X_XXXXS"); shuffle($array7); /////////////////////// $filename_reduced = explode(".swf",$filename); $file_name = $array1[0] . $array2[3] . ucfirst($array3[2]) . $array4[3] .$array6[4] . $array5[1] . "_". $array7[2] ."_" . $filename_reduced[0]; $new_path = "files/" . $file_name ; if(file_exists($new_path)){ die("You have already uploaded this file"); } elseif(move_uploaded_file($_FILES["swf"]["tmp_name"], "uploads/" . $file_name . ".swf")){ /* Create new directory for file */ mkdir($new_path,0700) or die("Error Creating File Directory"); /* Handle files */ $dir = "files/" . $file_name . "/index.php"; $ourFileHandle = fopen($dir, 'w') or die("can't open file"); fclose($ourFileHandle); $myFile = "files/" . $file_name . "/index.php"; $fh = fopen($myFile,"w") or die("can't open file"); $flashfile = '<style type="text/css"> <style type="text/css"> <!-- .style1 { font-family: Arial, Helvetica, sans-serif; font-size: 18px; } .copyright { font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #AEB6C1; text-decoration: none; } .style14 {color: #B8D09F} .style13 {color: #87A3A5} .style2 {color: #333333} .style4 { font-size: 36px; font-family: Arial, Helvetica, sans-serif; } .style5 {color: #B4E14A} .style7 { font-size: 14px; color: #CCCCCC; } .underline { border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-bottom-style: dashed; border-top-color: #CCCCCC; border-right-color: #CCCCCC; border-bottom-color: #CCCCCC; border-left-color: #CCCCCC; } --> </style> <center> <table width="46%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td align="center"><span class="style4"><span class="style5">Mega</span><span class="style13">Upload</span><br /> <span class="style7">Quick, and reliable swf uploading tool!</span></span> <hr size="1" class="underline" /></td> </tr> <tr> <td align="center" class="copyright"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" wcodebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'.$w.'" height="'.$h.'"> <param name="movie" value="../../uploads/'.$file_name.'.swf'.'" /> <param name="quality" value="high" /> <embed src="../../uploads/'.$file_name.'.swf'.'" height="'.$h.' width="'.$w.'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed> </object> </td> </tr> <tr> <td align="center" class="copyright"><span class="style2">2007-2008<strong> ©</strong></span><strong> <span class="style14">www.Flash-Portal.org</span></strong> <span class="style2">All Rights Reserved </span></td> </tr> </table> </center> '; $createfile = fwrite($fh,$flashfile); fclose($fh); setcookie("lastuser", $_SERVER['REMOTE_ADDR'], time()+5); header("Location: http://flash-portal.org/fp-upload/1/".$file_name); die(); } } } else // If form hasnt been submitted { echo "Error 312"; // Redirect the user to the proper page header("Location: http://flash-portal.org/fp-upload/1/index.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71118-solved-permission-denied/ Share on other sites More sharing options...
teng84 Posted September 29, 2007 Share Posted September 29, 2007 chek your folder property http://www.php.net/manual/en/function.chmod.php Quote Link to comment https://forums.phpfreaks.com/topic/71118-solved-permission-denied/#findComment-357653 Share on other sites More sharing options...
phpSensei Posted September 29, 2007 Author Share Posted September 29, 2007 thanks it worked, but now I get: Warning: fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid/gid is 24111/24111 is not allowed to access /mounted-storage/home45c/sub002/sc33159-IXOG/flash-portal.org/fp-upload/1/files/c5W96__XXX_x_x_X_riten owned by uid/gid 99/99 in /mounted-storage/home45c/sub002/sc33159-IXOG/flash-portal.org/fp-upload/1/do_upload.php on line 136 Warning: fopen(files/c5W96__XXX_x_x_X_riten/index.php) [function.fopen]: failed to open stream: No such file or directory in /mounted-storage/home45c/sub002/sc33159-IXOG/flash-portal.org/fp-upload/1/do_upload.php on line 136 can't open file i set all folders to 777 Quote Link to comment https://forums.phpfreaks.com/topic/71118-solved-permission-denied/#findComment-357655 Share on other sites More sharing options...
Cagecrawler Posted September 29, 2007 Share Posted September 29, 2007 Your host has safe mode active and it checks that the script and the file you're opening have the same owner. In this case, they don't. You can deactivate safe mode in php.ini if you have access to it. From PHP manual: Note: When safe mode is enabled, PHP checks whether the directory in which you are about to operate has the same UID (owner) as the script that is being executed. http://uk.php.net/fopen Also: http://uk.php.net/manual/en/features.safe-mode.php Quote Link to comment https://forums.phpfreaks.com/topic/71118-solved-permission-denied/#findComment-357658 Share on other sites More sharing options...
teng84 Posted September 29, 2007 Share Posted September 29, 2007 check your directory i guess your opening the wrong dir Quote Link to comment https://forums.phpfreaks.com/topic/71118-solved-permission-denied/#findComment-357666 Share on other sites More sharing options...
phpSensei Posted September 29, 2007 Author Share Posted September 29, 2007 I fixed it guys, thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/71118-solved-permission-denied/#findComment-357702 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.