-
one of these times I will get it right :)
PHP Code:
<html>
<?php
if (trim($_FILES['userfile']['tmp_name'])!="none" and trim($_FILES['userfile']['tmp_name'])!="" and trim($_FILES['userfile']['name'])!="") {
if(!copy($_FILES['userfile']['tmp_name'], "/home/duke/webroot/files/" . $_FILES['userfile']['name']."")){
echo "failed to copy!";
exit;
}
} else {
echo "Possible file upload attack. Filename: " . $_FILES['userfile']['name'];
}
?>
</html>
-
Possible file upload attack. Filename: wood096.jpg
-
ok, i just got a random american to test it, and it works for him
-
then your file is not getting to the server. it was "none" or empty.
do you have a firewall or something that is stopping it. becasue it should work if you upload a file. what is the whole script?
also if it works for some people than it has to work for you.
-
i dont have a firewall or proxy, when u say whole script? that is the whole script and it isnt just me who it doesnt work for.
and the file isnt empty as its a .jpg, and ... is simply a .jpg
-
I know you put a file in there but the file isn't getting to the server in the temp upload directory. it gets lost in the transmission.
what is the form you use to upload the file?
-
<html>
<title>Upload Demo</title>
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10000">
File To Be Uploaded: <input name="userfile" type="file">
<BR><input type="submit" value="Upload">
</form>
</html>
-
erm, i think i know what the problem was
name="MAX_FILE_SIZE" value="10000"
ie 10k?
i just changed it to 100k and i just uploaded an image
-
what is the size of the image you are upoading? I know it shouldn't amtter but you only set the max_size to 10K, change it to 100K
other than that is should work for everybody not just random people.
-
:rolleyes: :rolleyes: :( :( :rolleyes: :rolleyes:
my bad
-
oh thats fine, at least you know now for next time :D
cool it works :D
-
yep, ty ty ty
now i remember the <HTML> bit, erm, what was the rest again? :D
thx again
-
lol, ok, just as io thought i got away with this problem, it suddenly craps out, i can upload files now, BUT it wont let me upload some files, varied 1s, like i upload a .txt file then i upload a .jpg then i try and upload a different .txt file it says possible file attack
any ideas?
-
well you haven't done any file extension checking so it shouldn't matter. you shold be able to upload everything and anything.
just make sure anything that is over 100K will not upload. add this
PHP Code:
<html>
<?php
$filesize=filesize($_FILES['userfile']['name']);
if ($filesize > $_REQUEST['MAX_FILE_SIZE']){
echo" you exceded teh max file size to be uploaded";
exit;
}
if (trim($_FILES['userfile']['tmp_name'])!="none" and trim($_FILES['userfile']['tmp_name'])!="" and trim($_FILES['userfile']['name'])!="") {
if(!copy($_FILES['userfile']['tmp_name'], "/home/duke/webroot/files/" . $_FILES['userfile']['name']."")){
echo "failed to copy!";
exit;
}
} else {
echo "Possible file upload attack. Filename: " . $_FILES['userfile']['name'];
}
?>
</html>
-
i'll add it, but i dont think that is the problem, coz some of the files that wouldnt upload were a matter of a few k, upload random files, and i bet ya it says the warning