monkeypaw201 Posted June 13, 2008 Share Posted June 13, 2008 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 Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 13, 2008 Share Posted June 13, 2008 I'm not an expert, but is your File Uploads variable enabled? Mine says (in cpanel): "File Uploads file_uploads Whether to allow HTTP file uploads. On" Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted June 13, 2008 Author Share Posted June 13, 2008 yes, as i said, it worked 4 times before it broke, and i didn't change anything Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 Chmod the folder to 755 and try it. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted June 13, 2008 Author Share Posted June 13, 2008 same error, i also tried 777 and same thing... Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 I see the problem. $_POST['state'] isn't set, so you have that extra / in front. This is causing your script to try to move it to a folder in the root filesystem directory, which you usually need to be root user or use sudo for. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted June 13, 2008 Author Share Posted June 13, 2008 that was it, thx Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 No problem. Can't believe I noticed that, lol. I'm so tired today. Quote Link to comment 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.