JustinMs66@hotmail.com Posted September 10, 2006 Share Posted September 10, 2006 i have a working uploading script. this is what i want added on:so i want it so that like if i select "Images" in the select box, it'l upload to "uploads/images/" and if i select "Movies" in the select box, it'l upload to "uploads/movies/"[img]http://www.csscobalt.com/33/uploads/cats/images/help_php_v02.JPG[/img]and like rite now i can get it to always upload to "uploads/images/", but i don't know how to say like:ok so "dir_pre" is the name of the select box, and "images" is the name of the option.if($_POST['dir_pre.images'])and the the rest of the code...followed by "?>"and then i start a new php code (<?php)and do the smame thing but:if($_POST['dir_pre.[b]movies[/b]'])and even if i select movies, it still only uploads to images. help? Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 10, 2006 Share Posted September 10, 2006 do you mean you want to give the dropdown a if condition.[code]<?phpif($uploads=="movie"){do somethink}elseif($uploads=="images"){do somethink}?>[/code]good luck. Quote Link to comment Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 10, 2006 Author Share Posted September 10, 2006 and if i wanted more than 2 folders, would i just do this?[code]<?phpif($uploads=="movies"){do somethink}elseif($uploads=="images"){do somethink}elseif($uploads=="Music"){do somethink}?>[/code]and wouldn't it be:if($_POST['dir_pre.movies']){instead of:if($uploads=="movies"){ Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 10, 2006 Share Posted September 10, 2006 example not tested yet!uplaods was the name of the select name="uplaods" within the select box i had images and movie[code]<?php$folder1="redarrow_movie";$folder2="justin_movie";$folder3="redarrow_images";$folder4="justin_images";if($uploads=="movie"){mkdir($folder1);mkdir($folder2);}elseif($uploads=="images"){mkdir($folder3);mkdir($folder4);}?>[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 10, 2006 Share Posted September 10, 2006 try[code]<?phpif (isset($_POST['dir_pre'])) { $dir_pre = $_POST['dir_pre']; $upload_dir = "uploads/$dir_pre/"; echo $upload_dir;}?><FORM method='POST'><select name="dir_pre"> <option value="movies">Movies</option> <option value="images">Images</option></select><input type="submit" name="submit" value="Submit">[/code] Quote Link to comment Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 10, 2006 Author Share Posted September 10, 2006 ...lol ok, but that is still only for 2 folders, redarrow. what if i want more than 2 folders. for example, Images, Movies, and Music? and what is "isset" ??? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 10, 2006 Share Posted September 10, 2006 Then just add another option to the select<option value="music">Music</option> Quote Link to comment Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 10, 2006 Author Share Posted September 10, 2006 ...i meant what do i put for the PHP code, not the HTML code. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 10, 2006 Share Posted September 10, 2006 So did I. The PHP code stays the same.Run my original snippet, then add the extra music option and run it again Quote Link to comment Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 10, 2006 Author Share Posted September 10, 2006 wait, what exactly does the PHP part of your code do? Quote Link to comment Share on other sites More sharing options...
Barand Posted September 10, 2006 Share Posted September 10, 2006 it does what I thought you were asking it to doIf user selects "Movies" set the upload folder to "uploads/movies"If user select "Images" set the upload folder to "uploads/images"If user select "Music" set the upload folder to "uploads/music" Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 10, 2006 Share Posted September 10, 2006 Here is a nice code for you to see how to make a dir with a dropdown box, Also show the dir that have been made from the mkdir.your notice in this code i have used @ to stop errors if the dir is empty.all you goto do is make a folder called pu .good luck.test.php[code]<?phpif($_POST['submit']){$folder="up";$folder1="$folder/redarrow_movie";$folder2="$folder/justin_movie";$folder3="$folder/redarrow_images";$folder4="$folder/justin_images";if($uploads=="movie"){mkdir($folder1);mkdir($folder2);}elseif($uploads=="images"){mkdir($folder3);mkdir($folder4);} }$dirpath = $folder; $dlist = @opendir($dirpath); echo "<table align='center' border='4' boredcolor='black'><td align='center'><br><b>This is the folders that you own</b><br>";$info = "<select name='dir'>";while ($read = @readdir($dlist)) {$info.="<option value='$read'>$read</option>";}@closedir($dlist); $info.="</select>";echo $info;?><form method="POST" action=""><br><b>Please choose a dir to upload to</b><br><select name="uploads"><option value="movie">movie</option><br><option value="images">images</option><br></select><br><br><input type="submit" name="submit" value="Make!"></form></td></table>[/code] Quote Link to comment Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 10, 2006 Author Share Posted September 10, 2006 wul i already have a whole bunch of code that i want...so what would help if you could do:[color=red]<?php[/color][color=green]if [/color]the directory is "Movies" [color=orange]//i'l put my code here[/color]and[color=green]if [/color]the directory is "Images" [color=orange]//i'l put my code here[/color]and[color=green]if[/color] the directory is "Music" [color=orange]//i'l put my code here[/color][color=red]?>[/color]and like tell me where i can insert my code... that would be a big help. 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.