billy_111 Posted June 14, 2010 Share Posted June 14, 2010 Hey, I'm trying to have a crack at some code i have bee following, don't know if this is in any way correct :-) but lets see what you guys think. So i need to upload and extract the contents of a ZIP file to a folder on the server called "reviewimages".. This is my method: public function UploadZIPFileToServer(){ move_uploaded_file($_FILES["zipfile"]["tmp_name"], "../reviewimages/" . $_FILES["zipfile"]["name"]); if(is_uploaded_file($_FILES['zipfile']['tmp_name'])){ $zipfilename = basename($_FILES['zipfile']['name']); $zip = zip_open($zipfilename); if ($zip) { while ($zip_entry = zip_read($zip)) { $fp = fopen($targetdir . zip_entry_name($zip_entry), "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp,"$buf"); zip_entry_close($zip_entry); fclose($fp); } } } zip_close($zip); } } And this is how i fire the method: if(isset($_POST['uploadZIP'])){ $message = Review::UploadZIPFileToServer(); echo '<script type="text/javascript">window.location = "http://'.$_SERVER['SERVER_NAME'].$sitename.'manage-reviews.php"</script>'; } <form enctype="multipart/form-data" action="" method="post" id="add-courses"> <table> <tr> <td class="width"><label for="image">Upload ZIP file : </label></td> <td><input type="hidden" name="MAX_FILE_SIZE" value="1000000000000" /><input type="file" name="zipfile" id="zipfile" value=""/></td> <td><input type="submit" name="uploadZIP" value="Upload" /></td> </tr> </table> </form> This uploads the ZIP file to the server into the "reviewimages" folder, but i need it to extract its contents which it does not do.. Any ideas? Thanks Billy Quote Link to comment https://forums.phpfreaks.com/topic/204786-upload-and-extract-zip-file/ Share on other sites More sharing options...
blacksharkmedia Posted June 14, 2010 Share Posted June 14, 2010 are there any errors in server logs? Quote Link to comment https://forums.phpfreaks.com/topic/204786-upload-and-extract-zip-file/#findComment-1072144 Share on other sites More sharing options...
billy_111 Posted June 15, 2010 Author Share Posted June 15, 2010 I don't get no errors, nothing at all.. That's why i am confused, it's simply not extracting the contents of the ZIP file.. What do you think? Quote Link to comment https://forums.phpfreaks.com/topic/204786-upload-and-extract-zip-file/#findComment-1072145 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.