Jump to content

choose upload directory


RTS

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

<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]<?php
if(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?
Link to comment
https://forums.phpfreaks.com/topic/17998-choose-upload-directory/
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.)

Archived

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

×
×
  • Create New...

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.