Page 1 of 4

Check my script?

Posted: Wed Feb 18, 2004 7:28 pm
by monkeyj
I'm trying to make a UPLOAD to FTP script through a form..
I don't know if I quite got it right or not..
I have the HTML form.. with..

Code: Select all

<form enctype="multipart/form-data" action="/anims/submit.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1572864">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
and in the PHP file I have...

Code: Select all

<?php 
if (is_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'])) &#123;
    copy($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/anims/upload");
&#125; else &#123;
    echo "Possible file upload attack. Filename: " . $_FILES&#1111;'userfile']&#1111;'name'];
&#125;
/* ...or... */
move_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/anims/upload");
?>
Am I doing somethign wrong?

Help?

Posted: Wed Feb 18, 2004 10:17 pm
by John Cartwright
What are the errors?

o.o none

Posted: Wed Feb 18, 2004 10:28 pm
by monkeyj
There is no error..
It wants me to download the PHP file..
both the submit.html and submit.php are on my desktop
and I have a folder called "anims" with "upload" in it..

the codes are:

HTML:

Code: Select all

<form enctype="multipart/form-data" action="submit.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1572864">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
PHP:

Code: Select all

<?php 
if (is_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'])) &#123;
    copy($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/anims/upload");
&#125; else &#123;
    echo "Possible file upload attack. Filename: " . $_FILES&#1111;'userfile']&#1111;'name'];
&#125;
/* ...or... */
move_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/anims/upload");
?>

Posted: Wed Feb 18, 2004 10:42 pm
by John Cartwright
Might be a stupid question but.. your running this on a server right?
both the submit.html and submit.php are on my desktop

Posted: Wed Feb 18, 2004 10:49 pm
by monkeyj
My bad, meant server.. and.. Yes I am..

And I tried it again.. and did get an error this time..

Warning: copy(/anims/upload): failed to open stream: No such file or directory in /home/hsphere/local/home/monkeyj/monkeyblast.com/submit.php on line 4

Warning: move_uploaded_file(/anims/upload): failed to open stream: No such file or directory in /home/hsphere/local/home/monkeyj/monkeyblast.com/submit.php on line 9

Warning: move_uploaded_file(): Unable to move '/tmp/phptRS7lX' to '/anims/upload' in /home/hsphere/local/home/monkeyj/monkeyblast.com/submit.php on line 9

new code

Posted: Wed Feb 18, 2004 10:51 pm
by monkeyj
Just to make sure we have the same code...

Code: Select all

<?php 
if (is_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'])) &#123; 
    copy($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/anims/upload"); 
&#125; else &#123; 
    echo "Possible file upload attack. Filename: " . $_FILES&#1111;'userfile']&#1111;'name']; 
&#125; 
/* ...or... */ 
move_uploaded_file($_FILES&#1111;'userfile']&#1111;'tmp_name'], "/anims/upload"); 
?>


ERROR:
Warning: copy(/anims/upload): failed to open stream: No such file or directory in /home/hsphere/local/home/monkeyj/monkeyblast.com/submit.php on line 3

Warning: move_uploaded_file(/anims/upload): failed to open stream: No such file or directory in /home/hsphere/local/home/monkeyj/monkeyblast.com/submit.php on line 8

Warning: move_uploaded_file(): Unable to move '/tmp/phpxgYcdl' to '/anims/upload' in /home/hsphere/local/home/monkeyj/monkeyblast.com/submit.php on line 8

Posted: Wed Feb 18, 2004 10:52 pm
by John Cartwright
"/anims/upload/" this directory exists right?

Also make sure you have set the permissions correctly

the directory should be http://localhost/monkeyj/anims/upload

Posted: Wed Feb 18, 2004 10:55 pm
by monkeyj
I wouldn't need the slash at the end would I?

but.. anims/upload does exist...

Which permissions?

Posted: Wed Feb 18, 2004 10:56 pm
by John Cartwright
umm most likely you will need it..

CHMOD the permissions... should be set to 777 i believe

Posted: Wed Feb 18, 2004 10:56 pm
by monkeyj
Put the slash.. It doesnt matter :P but.. yes.. anims/upload is up

Posted: Wed Feb 18, 2004 10:58 pm
by monkeyj
I can't find the permissions...

Posted: Wed Feb 18, 2004 10:58 pm
by John Cartwright
gimme a few min ima go and run this on my server

Posted: Wed Feb 18, 2004 10:59 pm
by monkeyj
k

Posted: Wed Feb 18, 2004 11:01 pm
by John Cartwright
BTW might want to blank out your directory..

instead of /home/domain/folder do like /home/****/folder

Posted: Wed Feb 18, 2004 11:03 pm
by monkeyj
:-/ well I got two domains running from one host..
and thats the way the host set it up...

and I'm not too smart when it comes to deleting stuff alrdy set up :P