norm188 Posted February 17, 2011 Share Posted February 17, 2011 I'm using the following code to create a folder from a text field and works fine. I would like to upload 3 files in the created folder. <?php // set our absolute path to the directories will be created in: $path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/'; if (isset($_POST['create'])) { // Grab our form Data $dirName = isset($_POST['dirName'])?$_POST['dirName']:false; // first validate the value: if ($dirName !== false && preg_match('~([^A-Z0-9]+)~i', $dirName, $matches) === 0) { // We have a valid directory: if (!is_dir($path . $dirName)) { // We are good to create this directory: if (mkdir($path . $dirName, 0775)) { $success = "Your directory has been created succesfully!<br /><br />"; }else { $error = "Unable to create dir {$dirName}."; } }else { $error = "Directory {$dirName} already exists."; } }else { // Invalid data, htmlenttie them incase < > were used. $dirName = htmlentities($dirName); $error = "You have invalid values in {$dirName}."; } } ?> <html> <head><title>Make Directory</title></head> <body> <?php echo (isset($success)?"<h3>$success</h3>":""); ?> <h2>Make Directory on Server</h2> <?php echo (isset($error)?'<span style="color:red;">' . $error . '</span>':''); ?> <form name="phpMkDIRForm" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Enter a Directory Name (Alpha-Numeric only): <input type="text" value="" name="dirName" /><br /> <input type="submit" name="create" value="Create Directory" /> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/227994-upload-files-in-new-created-folder/ Share on other sites More sharing options...
BlueSkyIS Posted February 17, 2011 Share Posted February 17, 2011 do you just need to know how to handle file uploads? http://www.google.com/search?client=safari&rls=en&q=php+file+upload&ie=UTF-8&oe=UTF-8 http://www.google.com/search?client=safari&rls=en&q=php+image+upload&ie=UTF-8&oe=UTF-8 Link to comment https://forums.phpfreaks.com/topic/227994-upload-files-in-new-created-folder/#findComment-1175655 Share on other sites More sharing options...
norm188 Posted February 17, 2011 Author Share Posted February 17, 2011 No i need to upload 3 files using the script i posted. The 3 files will be uploaded in the folder created by the script i posted. I tried to figure this out and googled for it all day yesterday. I appriciate your help Link to comment https://forums.phpfreaks.com/topic/227994-upload-files-in-new-created-folder/#findComment-1175661 Share on other sites More sharing options...
BlueSkyIS Posted February 17, 2011 Share Posted February 17, 2011 upload the files to the server and move them into the new directory. the first link in my post provides many tutorials on handling file uploads. here is the first one: http://www.tizag.com/phpT/fileupload.php Link to comment https://forums.phpfreaks.com/topic/227994-upload-files-in-new-created-folder/#findComment-1175670 Share on other sites More sharing options...
norm188 Posted February 17, 2011 Author Share Posted February 17, 2011 What a joke is the forum i'll ask it on a real forum where you get help delete my account num nuts and block my ip address too Link to comment https://forums.phpfreaks.com/topic/227994-upload-files-in-new-created-folder/#findComment-1175673 Share on other sites More sharing options...
Pikachu2000 Posted February 17, 2011 Share Posted February 17, 2011 What a joke is the forum i'll ask it on a real forum where you get help delete my account num nuts and block my ip address too No, actually the joke is when 'people' like you come in here expecting someone to gleefully write code for them, test it, and post it free of charge, then whine like a little baby when it doesn't happen. And don't worry, the thread won't be deleted; it'll be left here so the whole world can see your little nuggets of 'wisdom'. Link to comment https://forums.phpfreaks.com/topic/227994-upload-files-in-new-created-folder/#findComment-1175740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.