Jump to content


choose upload directory

  • Please log in to reply
1 reply to this topic

#1 RTS

  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 18 August 2006 - 11:42 PM

I am trying to have my upload form give users the option of choosing where to upload the file. Here is my upload form:
<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); }
any tips?

#2 AndyB

  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 12:49 AM

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.)
Legend has it that reading the manual never killed anyone.
My site

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users