RTS Posted August 18, 2006 Share Posted August 18, 2006 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"><tr><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'></td></tr></table>[/code]And here is my php upload script:[code=php:0]<?phpif(is_uploaded_file($_FILES['userfile']['tmp_name'])){ $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? Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 19, 2006 Share Posted August 19, 2006 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.) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.