Hey,
I'm trying to explore php upload. I've done a page from where the visitor can post a mail and browse for a file to attach.
The thing is that I tried to upload simple .txt files (.js as well) and it worked just fine. Then, I tried with .jpg, .doc, .html files and none of them were uploaded...
Why some pages can't be uploaded?
I put my code just below (picked up from php manual exemples). If anybody knew a solution, I would be happy to hear from him/her :-)

Thanks a lot in advance,
Fred.

//####################
//# Here is the form
//####################

<form name="message" ENCTYPE="multipart/form-data" method="POST" action="attach.php">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
Topic: <input type="text" name="topic" size="50" value="Sujet TEST"><br>
Attach a file:<input type="file" name="userfile">
<p></p>
<textarea name="text" cols="60" rows="15"">TEXT TEST: JUST TO CHECK HOW WELL IT RUNS
ACTUALLY :-)</textarea>
<p></p>
<input type="hidden" name="group" value="Group1">
<input type="submit" name="submit" value="Submit">
</form>

//########################
//# And here the attach.php
//########################

if(!isset($userfile))
{
//display alert.
}
else
{
if(is_uploaded_file($userfile))
{
$destination = $group . "/attached/" . $userfile_name;
$storage = $group . "/message.txt";
move_uploaded_file($userfile,$destination);
$create_file = fopen($storage,'w');
fwrite($create_file,$text);
fclose($create_file);
}
else
{
echo "Might be an attack via file upload: file " . $userfile .".";
echo "name: " . $userfile_name .", size: " . $userfile_size . ", type: " . $userfile_type . ".";
}

}
?>

the test is_uploaded_file($myFile) returns false depending on the file I try to upload.
There's not a question of size (all the files I try to upload are just test files I made < 1Ko).

    Write a Reply...