Note that there are some explanatory texts on larger screens.

plurals
  1. POScript failed to open stream
    primarykey
    data
    text
    <p>I am trying to set up an upload site and I am unable to get the script to upload the file. (All permissions are set to 777 for the upload folders.) I continue to get these errors:</p> <pre><code>Warning: move_uploaded_file(/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/Ace_planning_instructions.docx) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/content/44/9976344/html/tech/tech/js/upload.php on line 72 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpo89pGR' to '/var/chroot/home/content/44/9976344/html/tech/filemanager/uploads/Ace_planning_instructions.docx' in /home/content/44/9976344/html/tech/tech/js/upload.php on line 72 Error! Most likely upload directory doesn't have writable permissions or you didn't set it up correctly. </code></pre> <p>What can I do to fix or work around these errors?</p> <hr> <p>Here is my code:</p> <pre><code>&lt;?php require_once("../includes/dbconnect.php"); //Load the settings require_once("../includes/functions.php"); //Load the functions // Work-around for setting up a session because Flash Player doesn't send the cookies if (isset($_POST["PHPSESSID"])) { session_id($_POST["PHPSESSID"]); } session_start(); $upload_dir = (!empty($_POST["upload_dir"]))?strip_tags(str_replace("'","`",$_POST["upload_dir"])):getUploadDir($_SESSION["idUser"]); if($demo){ echo "Uploads disabled in demo!"; } else { $q="SELECT id,parentID FROM folders WHERE name='".$upload_dir."'"; $res=mysql_query($q); $rrr=mysql_fetch_assoc($res); $folderID=$rrr["id"]; if($rrr["parentID"]!=0){ $q2="SELECT name FROM folders WHERE id='".$rrr["parentID"]."'"; $res2=mysql_query($q2); $rrr2=mysql_fetch_assoc($res2); $tmpStr=$rrr2["name"]."/"; } else { $tmpStr = ""; } $uploadfile = $_SERVER['DOCUMENT_ROOT'].$script_dir.$tmpStr.$upload_dir."/".(str_replace(" ","_",$_FILES['Filedata']['name'])); $FileNametmp = $_FILES['Filedata']['name']; $fileNamePartstmp = explode(".", $FileNametmp); $counter2 = count($fileNamePartstmp)-1; $fileExtensiontmp = strtolower($fileNamePartstmp[$counter2]); // Estension (part behind last dot) $title=$FileNametmp; $fsize = filesize($_FILES['Filedata']['tmp_name']); $fileEXT = strtoupper($fileExtensiontmp); //get limits for current user. $sSQL = "SELECT id,username,filesize,quota,extensions FROM users WHERE id='".$_REQUEST["user"]."'"; $result = mysql_query($sSQL) or die("err: " . mysql_error().$sSQL); if($row = mysql_fetch_assoc($result)){ $max_filesize = $row["filesize"]; $extensionsArr = explode(",",$row["extensions"]); $sql2="SELECT SUM(size) userQuota FROM files WHERE userID='".$_REQUEST["user"]."'"; $result2=mysql_query($sql2) or die("error getting user files sizes"); $rr=mysql_fetch_assoc($result2); $max_quota = $row["quota"]; $current_quota = $rr["userQuota"]; } $upload=false; //validations if($current_quota&lt;($max_quota * 1024 * 1024)){ if($current_quota + $fsize &lt;=($max_quota * 1024 * 1024)){ if($fsize&lt;=($max_filesize * 1024 * 1024)){ for($i=0;$i&lt;count($extensionsArr);$i++){ if($extensionsArr[$i]==$fileEXT){ $upload=true; } } if($upload){ //everything ok, upload file. //if($fileEXT=="EXE" || $fileEXT=="COM" || $fileEXT=="BAT" || $fileEXT=="HTM" || $fileEXT=="HTML" || $fileEXT=="PHP" || $fileEXT=="JS"){ //addLog($_SESSION["idUser"],"forbidden file upload $title "); //$msg = "Such files are forbidden in demo version."; //} else { //$filePath=uploadFile($_FILES['file'], $upload_dir.$title."_".$_SESSION["idUser"].".".$fileExtensiontmp); if(move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile )){ $sSQL="INSERT INTO files (title,path,size,extension,userID,catID,dateUploaded) VALUES ('".$title."','".$script_dir.$tmpStr.$upload_dir."/".str_replace(" ","_",$_FILES['Filedata']['name'])."','".$fsize."','".$fileExtensiontmp."','".$_REQUEST["user"]."','".$folderID."',NOW())"; mysql_query($sSQL) or die("Invalid query: " . mysql_error() . " - $sSQL"); addLog($_REQUEST["user"],"Uploaded file $title "); $msg = "You have successfully uploaded file $title "; $notice = sendNotice('notify_upload'); if($notice){ //send notice to system mail send_mail("New file uploaded!", getUser($_REQUEST["user"])." have successfully uploaded file $title"); } } else { $msg = "Error! Most likely upload directory doesn't have writable permissions or you didn't set it up correctly. "; } //} } else { $msg = "Not allowed file extension $fileEXT! "; addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'Not allowed file extension\' "); } } else { $msg = "File size is larger than you maximum allowed size limit."; addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'File size is larger than you maximum allowed size limit.\' "); } } else { $msg = "Not enough space left for you on the server. Try deleting some files."; addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'Not enough space left for you on the server. Try deleting some files.\' "); } } else { $msg = "Your upload quota has been reached. Try deleting some files."; addLog($_REQUEST["user"],"Error! Tried to upload $title. Got \'Your upload quota has been reached. Try deleting some files.\' "); } //send_mail("Email Notify",$msg); echo $msg; } exit(0); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload