PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 7:28 pm
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ї'userfile']ї'tmp_name'])) {
copy($_FILESї'userfile']ї'tmp_name'], "/anims/upload");
} else {
echo "Possible file upload attack. Filename: " . $_FILESї'userfile']ї'name'];
}
/* ...or... */
move_uploaded_file($_FILESї'userfile']ї'tmp_name'], "/anims/upload");
?>
Am I doing somethign wrong?
Help?
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 10:28 pm
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ї'userfile']ї'tmp_name'])) {
copy($_FILESї'userfile']ї'tmp_name'], "/anims/upload");
} else {
echo "Possible file upload attack. Filename: " . $_FILESї'userfile']ї'name'];
}
/* ...or... */
move_uploaded_file($_FILESї'userfile']ї'tmp_name'], "/anims/upload");
?>
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Feb 18, 2004 10:42 pm
Might be a stupid question but.. your running this on a server right?
both the submit.html and submit.php are on my desktop
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 10:49 pm
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
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 10:51 pm
Just to make sure we have the same code...
Code: Select all
<?php
if (is_uploaded_file($_FILESї'userfile']ї'tmp_name'])) {
copy($_FILESї'userfile']ї'tmp_name'], "/anims/upload");
} else {
echo "Possible file upload attack. Filename: " . $_FILESї'userfile']ї'name'];
}
/* ...or... */
move_uploaded_file($_FILESї'userfile']ї'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
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 10:55 pm
I wouldn't need the slash at the end would I?
but.. anims/upload does exist...
Which permissions?
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Feb 18, 2004 10:56 pm
umm most likely you will need it..
CHMOD the permissions... should be set to 777 i believe
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 10:56 pm
Put the slash.. It doesnt matter
but.. yes.. anims/upload is up
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 10:58 pm
I can't find the permissions...
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Feb 18, 2004 10:58 pm
gimme a few min ima go and run this on my server
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 10:59 pm
k
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Feb 18, 2004 11:01 pm
BTW might want to blank out your directory..
instead of /home/domain/folder do like /home/****/folder
monkeyj
Forum Commoner
Posts: 82 Joined: Mon Dec 15, 2003 4:32 pm
Location: USA
Contact:
Post
by monkeyj » Wed Feb 18, 2004 11:03 pm
:-/ 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