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
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.)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.