|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
File upload not recognized.
I have a simple script which uploads a single file. It works great on another server, but not this one. Here is the script
Code:
<?php
if (is_uploaded_file($_FILES['filename']['tmp_name']))
{
$filename = $_FILES['filename']['tmp_name'];
$realname = $_FILES['filename']['name'];
copy($_FILES['filename']['tmp_name'], $realname);
}
else
{
echo "Possible file upload attack: filename".$_FILES['userfile']['name'].".";
}
?>
It goes directly to the else in this statement. I then tried printing the $_FILES['filename']['tmp_name']; stuff and there is nothing in the there. Any ideas why it is not recognizing the file. Also I checked the variables in the phpinfo and the variable from the form is adding on an extra backslash. see below. C:\stuff\file.cvs That double \ before file should not be there. COuld this be causing the problem? |
|
#2
|
|||
|
|||
|
RE: File upload not recognized.
what version of PHP is running on this new server? is_uploaded_file() is available only in versions of PHP 3 after PHP 3.0.16, and in versions of PHP 4 after 4.0.2. extra slashes could definately be causing a problem, yah.. also the "$_FILES" was introduced in PHP 4.1.0 - in earlier versions, use $HTTP_POST_FILES.
|
|
#3
|
|||
|
|||
|
RE: File upload not recognized.
I have the version of PHP 4.2.2.
I belive that the double slashed are the main problem. How do I fix that? |
|
#4
|
|||
|
|||
|
RE: File upload not recognized.
can we see some more code please? the html form and the code which processes it.. gotta know exactly where the slash is being added in order to fix it
|
|
#5
|
|||
|
|||
|
Here is the html part
Code:
<form name="form1" method="post" action="upload.php">
<table width="500" border="0" align="center" cellpadding="1" cellspacing="0">
<tr>
<td><p align="center"><font color="#336699" size="4" face="Arial, Helvetica, sans-serif"><strong>Upload File</strong></font></p></td>
</tr>
<tr>
<td bgcolor="#336699">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="29%" height="40" align="right" bgcolor="#FFFFFF"><font size="2" face="Arial, Helvetica, sans-serif">File: </font></td>
<td width="71%" height="40" bgcolor="#FFFFFF"> <input type="file" name="filename"> </td>
</tr>
<tr valign="top">
<td height="40" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="Upload"></td>
</tr></table></td></tr></table>
|
|
#6
|
|||
|
|||
|
RE: File upload not recognized.
couple things right off the bat.. i can't see where any slashes are being added but your form tag should include the enctype: <form enctype="multipart/form-data">
you should specify the max size allowed: <input type="hidden" name="MAX_FILE_SIZE" value="1000"> all kinds of additional uploading information can be found here |
|
#7
|
|||
|
|||
|
RE: File upload not recognized.
Thank you the <form enctype="multipart/form-data"> was what was missing. It works beautiful now.
Good Job! |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > File upload not recognized. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|