I'm trying to rename an uploaded file with the value of a select I have
in the uploaded form. Can someone point me in the right direction. The
PHP.net rename manual isn't helping a lot? My code:

//Form for upload
<form enctype="multipart/form-data" action="eshop_upload.php"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="25000">
<input type="file" name="userfile" size="18" class="kapea">
<br><br>
<span class="adminisoleipa">Select the category to add the picture
to:<br><br>
<select name='category'>
<option value="">Please select...</option>
<? 
        while ($array = mysql_fetch_array($mysql))
        {    
        echo "<option
value='{$array["catid"]}'>{$array["catname"]}</option>";
        }
?>
</select>
</td>
</tr>
<tr><td><br>
<input type="submit" name="Submit" value="Submit" class="nappi">
</form>

//eshop_upload.php
<?php
// Upload the picture to the selected directory and rename the file as
the category number.
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
        {
        
copy($HTTP_POST_FILES['userfile']['tmp_name'],"http://www.violasystems.c
om/images/");
        rename("($HTTP_POST_FILES['userfile']['tmp_name'])",
"$category");
        }
else
        {
        echo "Possible file upload attack. Filename:"
.$HTTP_POST_FILES['userfile']['tmp_name']
        }
?>

TIA.

Steve Jackson
Web Developer
Viola Systems Ltd.
http://www.violasystems.com
[EMAIL PROTECTED]
Mobile +358 50 343 5159


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to