Redcircle may be right about the register globals!
For the 'Unlink failed' error, try to check the directory permission!
Or try this code:
- Code: Select all
<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
upload file:
<input type='file' size='40' name='imagefile' maxlength='255'>
<input type='hidden' name='MAX_FILE_SIZE' value='500000'>
<input type="submit" value="upload">
</form>
[php]<?
// Replace 'x' with the complete path to where you want upload!
$uploaddir = "x";
if(($HTTP_POST_FILES['imagefile']['type'] == "image/gif")){
$file_realname = trim($HTTP_POST_FILES['imagefile']['name']);
move_uploaded_file($HTTP_POST_FILES['imagefile']['tmp_name'], $uploaddir . $file_realname) or die ("Could not copy the file");
echo "File uploaded succesfuly!"; }
else{
echo "Wrong Filetype ".$HTTP_POST_FILES['imagefile']['name']";
}
?>[/php]