justAnoob Posted March 25, 2009 Share Posted March 25, 2009 I have a list menu of a couple categories. I have a folder on my server called userimages with the category sub folders off of that. Right now we got a upload script to upload all pictures to the main userimages folder. How would I go about intergrating a list menu so the user can pick the category he or she would like the file to go into. Here is what I got so far. <?php $image_name=time().'.'.$extension; $newname="userimages/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); ?> Any tutorials out there or step by steps or any ideas. Thanks again. Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 25, 2009 Share Posted March 25, 2009 assuming your upload script is working currently, you should have a path where the images are currently getting uploaded. have another item in your form, a SELECT menu with the possible subcategories, then take the entry they selected and insert it into the path where the file will be going in theory Quote Link to comment Share on other sites More sharing options...
justAnoob Posted March 25, 2009 Author Share Posted March 25, 2009 upload script works properly, all files just go to main userimages folder. I have sub folders created already. How would I go about the whole variable thing... something like this??>>>>> <?php $listmenu = $image_name=time().'.'.$extension; $newname="userimages/$listmenu/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); ?> the list menu options are named identical to the sub folder names just so you know Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 25, 2009 Share Posted March 25, 2009 you'd have to post the form code where the user selects the file to upload Quote Link to comment Share on other sites More sharing options...
justAnoob Posted March 25, 2009 Author Share Posted March 25, 2009 Here is what I got,,, I'm only showing the code that is relevant to what I am trying to accomplish The "*****" are the lines that I started to change for this to work, not sure if that is correct though. <?php if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "gif") && ($extension != "png")) { echo '<h1>Unknown extension!</h1>'; $errors=1; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } $listmenu = //****** $image_name=time().'.'.$extension; $newname="userimages/$listmenu/".$image_name; //********* $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } } } } ?> Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted March 25, 2009 Share Posted March 25, 2009 thats basically the idea that you want. you just need to populate $listmenu with the $_POST value of the SELECT from your form Quote Link to comment Share on other sites More sharing options...
justAnoob Posted March 25, 2009 Author Share Posted March 25, 2009 the list is populated already with the categories... I'm using dreamweaver for this small page i'm doing. what is the next step?? Quote Link to comment Share on other sites More sharing options...
justAnoob Posted March 25, 2009 Author Share Posted March 25, 2009 bump, ttt... cant find anything on google about list menus and category selection 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.