PDA

View Full Version : Upload script with directory selection..



sWo0p
January 27th, 2005, 09:33 AM
Im working currently of a PDF upload section to a site but im stuc a little, i need to upload to sevral subdirs.. i have my uploadscript working fine but now i need to enter a section to select in what directory they can upload.. with a selectbox



<?


function getext($filename,$tolower = true) {
$split = explode (".", $filename);
$index = (count($split) - 1);
return ($tolower ? strtolower($split[$index]) : $split[$index]);
}


$path = $_SERVER['DOCUMENT_ROOT']."M:\\hosting\\web\\prijs_lijst_pdf\\";

if(isset($_POST['upload'])){

if (!empty($_FILES['file']['name'])){
$formats = array('exe','mov','swf'); //* lijst met verboden file extensies, lowercase *//

if(in_array(getext($_FILES['file']['name']),$formats)) {
echo "<br>&nbsp;&nbsp;<font class=\"error\">U heeft een verboden bestands type uit gekozen..!</b>"; //* file extentie error message *//
} else {

if(!is_dir($path)) mkdir("$path" . $_POST['dir'], 0777);
copy($_FILES['file']['tmp_name'], $path . $_FILES['file']['name']);
unlink($_FILES['file']['tmp_name']);
echo "<br>&nbsp;&nbsp;<font class=\"error\">Bestand geupload met succes..<Br>";
}

} else {

echo "";
exit();

}
}


?>
<br>



<table cellspacing="2" cellpadding="2" border="0">
<form enctype="multipart/form-data" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<tr>
<td><input type="file" size="20" name="file">&nbsp;

<select name="welk">
<option>--Upload directory--
<option>Rrijslijst
<option>Verhuur
<option>Prefab
<option>Gereedschap
</select></td>
<td></td>
</tr>
<tr>
<td>
<br><input type="submit" name="upload" value="Upload"></td>
<td></td>
</tr>
</table>

</form>


this is what i have currently.. :trout:

amitgeorge
January 27th, 2005, 03:05 PM
hmm... you cant do that....

must select each file.... one by one

however...

you could ask the user to zip the folder and hen upload it.... which you can unzip on the server.??
:thumb:

Danno
February 1st, 2005, 01:17 AM
let me see if i understand you correctly... ok?

you have a page that allows the user to browse their computer to upload a PDF. Currently, it uploads to :


$path = $_SERVER['DOCUMENT_ROOT']."M:\\hosting\\web\\prijs_lijst_pdf\\";

when they are choosing the PDF to upload, would you like that PDF selected to be uploaded to multiple directories, or would you like to have their be a drop down list right next to the "select the PDF to upload..." with a list of available directories they can upload it into?

either way can be done, but before i can answer more in depth, i'll need to know that.

Danno~