Jump to content

Uploads Folder, Selected By Select Box? need help!


JustinMs66@hotmail.com

Recommended Posts

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?
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

try
[code]<?php
if (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]
Link to comment
Share on other sites

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]
<?php

if($_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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.