|
-
Jun 17th, 2005, 04:42 AM
#1
Thread Starter
Hyperactive Member
[Resolved] Upload error
<?php
$directory = '/public_html/';
echo "user file = $userfile<br>\n";
echo "user file name = $userfile_name<br>\n";
echo "user file size = $userfile_size<br>\n";
echo "user file type = $userfile_type<br>\n";
if (!copy($userfile, $directory.$userfile_name)) {
print("failed to copy $userfile...<br>\n");
}
if ( $userfile_type == 'text/plain' ) {
}
else if ( ($userfile_type == 'image/pjpeg') ||
($userfile_type == 'image/bmp') ||
($userfile_type=='image/gif') ) {
echo "<img src=images/$userfile_name><br>\n";
}
?>
-------------------------------------
user file = /tmp/phpC48Bsi
user file name = hp.txt
user file size = 15230
user file type = application/octet-stream
Warning: copy(/public_html/hp.txt): failed to open stream: No such file or directory in /home/ebay555/public_html/fileupload.php on line 8
failed to copy /tmp/phpC48Bsi...
what am i mistake?
thanks
Last edited by naruponk; Jun 18th, 2005 at 10:04 PM.
-
Jun 17th, 2005, 11:34 AM
#2
Re: Upload error
You might want to use the method described in the PHP docs instead.
Pay special attention to the user comments, as they list a lot of possible security holes. (I found at least one of them in your code.)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 17th, 2005, 10:17 PM
#3
Thread Starter
Hyperactive Member
Re: Upload error
I think it may cause of permission
if so, how can i set the permission on FTP?
any other idea?
thanks
-
Jun 18th, 2005, 03:00 AM
#4
Re: Upload error
Depends on your FTP client. The command line client uses the chmod command.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 18th, 2005, 03:56 AM
#5
Thread Starter
Hyperactive Member
Re: Upload error
Do you think my code is correct or not?
-
Jun 18th, 2005, 04:14 AM
#6
Re: Upload error
I think it's a security risk, but it should work, provided that register_globals is enabled.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 18th, 2005, 07:32 PM
#7
Fanatic Member
Re: Upload error
the problem is mostlikly NOT in the permissions... the problem is (i think) this:
PHP Code:
<?php
$directory = '/public_html/';
...
if (!copy($userfile, $directory.$userfile_name)) {...
look, is there a file on the server in the location: "/public_html/blablabla.txt"? no, the file should be: "./public_html/blablabla.txt"
chave the $directory = to:
PHP Code:
$directory = './public_html/';
and try it
-
Jun 18th, 2005, 10:05 PM
#8
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|