Jump to content

[SOLVED] File Upload: permission denied


monkeypaw201

Recommended Posts

so, i use the following script:

 

<?
if(isset($_FILES['zip'])){
require_once('pclzip.php'); 

$upload_dir = $_POST['state']; 
$filename = $_FILES['zip']['name'];

//move file
if(move_uploaded_file($_FILES['zip']['tmp_name'], $upload_dir.'/'.$filename)){
     echo "<em>Uploaded ". $filename . " - ". $_FILES['zip']."</em><br />";
}else{
  die("<font color='red'>Error : Unable to upload file</font><br />");}

$zip_dir = substr(basename($filename, ".zip"),4,4); 

if(!@mkdir($upload_dir.'/'.$zip_dir, 0777))
  die("<font color='red'>Error : Unable to create directory</font><br />");

$archive = new PclZip($upload_dir.'/'.$filename);

if ($archive->extract(PCLZIP_OPT_PATH, $upload_dir.'/'.$zip_dir) == 0)
  die("<font color='red'>Error : Unable to unzip archive</font>");

$list = $archive->listContent();
echo "<br /><b>Files unzipped and added:</b><br />";
for ($i=0; $i<sizeof($list); $i++) {

  if(!$list[$i]['folder'])
   $bytes = " - ".$list[$i]['size']." bytes";
  else
   $bytes = "";
  
  echo "".$list[$i]['filename']."<br />";
}

unlink($upload_dir.'/'.$filename); 

}

include_once("upload.html");
?>

 

and recieve the following errors.. not sure whats wrong, it worked 4 times and then began throwing errors...

 

Warning: move_uploaded_file(/day-K4A9_20080613165714.zip) [function.move-uploaded-file]: failed to open stream: Permission denied in /upload.php on line 9

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpTVYjCk' to '/day-K4A9_20080613165714.zip' in /upload.php on line 9

Error : Unable to upload file

Link to comment
https://forums.phpfreaks.com/topic/110137-solved-file-upload-permission-denied/
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.