Jump to content


This topic is now archived and is closed to further replies.


choose upload directory

Recommended Posts

I am trying to have my upload form give users the option of choosing where to upload the file. Here is my upload form: [code]<table width="330" cellpadding="0" cellspacing="3">


<td background="table.jpg"

width="300" hight="500"
style="border-top:4px #000000 solid;border-bottom:4px #000000
    solid;border-right:4px #000000 solid;border-left:4px #000000 solid;">
<h3 align="center"><font color="white">Upload File!</font><h3>
<form enctype='multipart/form-data' action='upload.php' method='post'>
<input name='userfile' type='file'>
<input type='submit' value='Upload'>
And here is my php upload script:
$uploadfile = str_replace("upload.php", "uploads/", $_SERVER['SCRIPT_FILENAME']) . str_replace(' ', '', strtolower(basename($_FILES['userfile']['name'])));   
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile); }
      ?> [/code]
any tips?

Share this post

Link to post
Share on other sites
If you want users to be able to choose the folder to which files are uploaded, then your form will need to provide them with some options or method of identifying the folder.  The posted code doesn't.

I would be VERY careful with this, and only allow the users to choose from a pre-determined set of folders for their upload destination (otherwise they'll be strewing their files all over your server and/or naming non-existent folders.)

Share this post

Link to post
Share on other sites


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.