Canman2005 Posted August 7, 2007 Share Posted August 7, 2007 Hi all Wondering if you can help me. Basically, I have a script which allows you to upload a zip file, the script then creates a folder and the zip file is then dumped on the server into that folder location, the scrip then takes the uploaded zip file and extracts the files. The code im using is <?php if ($_POST['action'] == 'add') { $rand = rand(100,999); mkdir('zipfiles/'.$rand.''); $upload_folder = 'zipfiles/'.$rand.'/'; $upload_factsheets = str_replace("'", "", $upload_folder.$rand.$_FILES['fs']['name']); if (move_uploaded_file($_FILES['fs']['tmp_name'], $upload_factsheets)) { system('unzip "'.$upload_factsheets.'"'); print $upload_factsheets; } else { print "<script>alert ('There was a problem with your file');</script>"; } } ?> <form method="post" enctype="multipart/form-data"> <input name="fs" type="file" class="style11normblack" id="fs" /> <input name="Submit" type="submit" class="style11normblack" value="Add" /> <input name="action" type="hidden" id="action" value="add" /> </form> The problem is that the above script dumps the zip files into the same folder as the php page is in, I cant seem to set a target folder for the unzipped files. Does anyone know how I can target the zip file to unzip the files into the same folder as the zip file is uploaded. Does that make sense? Thanks in advance Ed Link to comment https://forums.phpfreaks.com/topic/63759-upload-and-extract-question/ Share on other sites More sharing options...
NArc0t1c Posted August 7, 2007 Share Posted August 7, 2007 try using this: $upload_folder = $_SERVER['DOCUMENT_ROOT'] . '/'.$rand.'/'; Link to comment https://forums.phpfreaks.com/topic/63759-upload-and-extract-question/#findComment-317742 Share on other sites More sharing options...
The Little Guy Posted August 7, 2007 Share Posted August 7, 2007 try adding this slash: $upload_folder = '/zipfiles/'.$rand.'/'; Link to comment https://forums.phpfreaks.com/topic/63759-upload-and-extract-question/#findComment-317744 Share on other sites More sharing options...
wildteen88 Posted August 7, 2007 Share Posted August 7, 2007 Not sure but perhaps use: $path = $upload_folder . $upload_factsheets; system('unzip "'.$path.'"'); Link to comment https://forums.phpfreaks.com/topic/63759-upload-and-extract-question/#findComment-317746 Share on other sites More sharing options...
Barand Posted August 7, 2007 Share Posted August 7, 2007 At the command prompt, try entering unzip /help or unzip ? that usually gives list of command line args that can be used Link to comment https://forums.phpfreaks.com/topic/63759-upload-and-extract-question/#findComment-317749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.