dftg Posted June 1, 2012 Share Posted June 1, 2012 Hey everyone. I'm still pretty wet behind the ears when it comes to php, so let me just say thanks in advance. I'm trying to write a php script that will: [*]create a directory with a name that is either the current date or a name of my choosing. [*]accept a zip file upload into that directory. [*]unzip the file so it's just the files within the directory. ..and that's enough to start off. Here's my code so far: part 1: <html> <head> <title>upload part 1</title> </head> <body> <center> <h1>Upload form part 1</h1> <!--specify form action for html--> <form action="upload2.php" method="post"> <?php // create new folder for event $folder_name = date("mdy"); ?> <!--textarea for inputting folder name with preset of current date.--> <p>Folder name? <input type="text" name="folder_name" size="30" maxlength="50" value=" <?php echo $folder_name; ?> " <!--upload a file--> <input type="submit" name="submit" value="Make directory!" /> </form> </center> </body> </html> part 2: <?php $dirname = $_POST['folder_name']; if (is_dir($dirname) === true){ echo $dirname . " exists"; } else { mkdir("$dirname", 0755); } if (isset($_POST['submitted'])) { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], '$dirname')) { echo "the file " . basename( $_FILES['UPLOADEDFILE']['NAME']) . " has been uploaded."; } else { echo "problem uploading/moving file."; } echo '<p><font color="red">Please upload a zip file.</font></p>'; } // End of the submitted conditional. ?> <html> <body> <form enctype="multipart/form-data" action="upload2.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="3000000"> <fieldset><legend>Select a zip file to be uploaded:</legend> <p><b>File:</b> <input type="file" name="upload" /></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </body> </html> Currently I'm getting the error message "Warning: mkdir() [function.mkdir]: No such file or directory in /home/content/G/r/a/Gravid/html/headfirst/uploadtest.php on line 8" and I've tried different things and I'm not sure why I'm getting that. Any thoughts? A couple more questions... I pretty much modified some code I found in the peachpit press visual quickstart guide to php6 and mysql5, and as a result I don't understand something about this code. the part where it says "['uploaded']['tmp_name']" - what do the "uploaded" and "tmp_name" mean and why are they there? Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/263456-noob-creating-and-populating-directories/ Share on other sites More sharing options...
dftg Posted June 6, 2012 Author Share Posted June 6, 2012 I seem to be getting a different result based on what browser I'm using, I get an error message in firefox, and pretty much almost no results outside of the basic html printing out when I use IE. Quote Link to comment https://forums.phpfreaks.com/topic/263456-noob-creating-and-populating-directories/#findComment-1351618 Share on other sites More sharing options...
dftg Posted June 12, 2012 Author Share Posted June 12, 2012 I'm really at an impasse here, can anyone help me out? Quote Link to comment https://forums.phpfreaks.com/topic/263456-noob-creating-and-populating-directories/#findComment-1353083 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.