Jump to content


Photo

Uploads Folder, Selected By Select Box? need help!


  • Please log in to reply
12 replies to this topic

#1 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 10 September 2006 - 08:32 AM

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/"
Posted Image
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.movies'])

and even if i select movies, it still only uploads to images. help?

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 September 2006 - 09:02 AM

do you mean you want to give the dropdown a if condition.
<?php

if($uploads=="movie"){

do somethink

}elseif($uploads=="images"){

do somethink

}
?>

good luck.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 10 September 2006 - 09:18 AM

and if i wanted more than 2 folders, would i just do this?

<?php
if($uploads=="movies"){
do somethink
}elseif($uploads=="images"){
do somethink
}elseif($uploads=="Music"){
do somethink
}
?>

and wouldn't it be:
if($_POST['dir_pre.movies']){
instead of:
if($uploads=="movies"){


#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 September 2006 - 09:23 AM

example not tested yet!

uplaods was the name of the select name="uplaods" within the select box i had images and movie

<?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);
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 September 2006 - 09:26 AM

try
<?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">

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 10 September 2006 - 09:27 AM

...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" ???


#7 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 September 2006 - 09:30 AM

Then just add another option to the select

<option value="music">Music</option>
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#8 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 10 September 2006 - 09:33 AM

...i meant what do i put for the PHP code, not the HTML code.

#9 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 September 2006 - 09:37 AM

So did I. The PHP code stays the same.

Run my original snippet, then add the extra music option and run it again
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#10 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 10 September 2006 - 09:45 AM

wait, what exactly does the PHP part of your code do?

#11 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 September 2006 - 09:50 AM

it does what I thought you were asking it to do

If 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"

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#12 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 10 September 2006 - 10:15 AM

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

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#13 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 10 September 2006 - 09:09 PM

wul i already have a whole bunch of code that i want...
so what would help if you could do:

<?php
if the directory is "Movies"
//i'l put my code here
and
if the directory is "Images"
//i'l put my code here
and
if the directory is "Music"
//i'l put my code here
?>

and like tell me where i can insert my code... that would be a big help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users