The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Files Upload Help
Discuss Files Upload Help in the PHP Development forum on Dev Shed. Files Upload Help PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 3rd, 2000, 10:34 AM
|
|
Contributing User
|
|
Join Date: Mar 2000
Location: Hong Kong
Posts: 73
Time spent in forums: 6 h 31 m 9 sec
Reputation Power: 14
|
|
|
I have no idea what is wrong in my codes,
and I got the following error message:
"Warning: Unable to open 'C:test.txt' for reading: No such file or directory in /www/upload.phtml on line 20"
here is my HTML and PHP codes:
(HTML code):
<FORM ACTION="upload.phtml" METHOD=POST ENCTYPE=multipart/form-data">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="10000">
Submit this file: <INPUT TYPE=FILE NAME="userfile"><BR>
<INPUT TYPE=SUBMIT><BR>
(PHP code):
<?php
if (copy($userfile, "../temp/$savefile")){
echo(" File Saved Successfully. ");
}
else {
echo (" Error, file cannot be saved.");
}
?>
I have no idea what is wrong.
Please help.
|

April 4th, 2000, 03:12 AM
|
|
Contributing User
|
|
Join Date: Dec 1999
Location: Netherlands
Posts: 77
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by ccm:
I have no idea what is wrong in my codes,
and I got the following error message:
"Warning: Unable to open 'C:test.txt' for reading: No such file or directory in /www/upload.phtml on line 20"
[/quote]
Hi,
From the error message I suppose you tried to upload a file to a windows machine (default "C:test"), or not?
When that is the case, be sure to add $userfile = stripslashes($userfile); before you do anything with it.
Let me know,
Peter
|

April 4th, 2000, 03:21 AM
|
|
Contributing User
|
|
Join Date: Mar 2000
Location: Hong Kong
Posts: 73
Time spent in forums: 6 h 31 m 9 sec
Reputation Power: 14
|
|
|
Hello PAV
thanks for your reply.
What I am doing now is to make
a homepage for a user uploading their files.
Then I put their files into a specified directory.
The webserver is running on a Linux machine.
umm...
ahh
I have no idea what to do next. Pls help.
|

April 4th, 2000, 09:45 AM
|
|
Contributing User
|
|
Join Date: Dec 1999
Location: Netherlands
Posts: 77
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
How can you have a file on a Linux machine with a name of 'C:test.txt'?
Please give more info on the upload.phtml file, because I don't see a line 20. The part I can see looks OK.
Peter
|

April 4th, 2000, 08:09 PM
|
|
Junior Member
|
|
Join Date: Mar 2000
Location: Hong Kong
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hello PAV, this is ccm using another account.
I think I have some mis-understanding on the function copy().
How does one send a file from a browser?
eg. sending a resume.txt to a job application website.
I though this HTML codes will do it:
<FORM ACTION="upload.phtml" METHOD=POST ENCTYPE=multipart/form-data">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="10000">
Submit this file: <INPUT TYPE=FILE NAME="userfile"><BR>
<INPUT TYPE=SUBMIT>
where is the file $userfile go?
in a temp directory in a webserver?
How do I copy that file to a specified directory?
I thought copy($userfile, ..pathfilename) will do the trick....
|

April 5th, 2000, 04:43 AM
|
|
Contributing User
|
|
Join Date: Dec 1999
Location: Netherlands
Posts: 77
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
Everything you say and want to do is right. The $userfile is stored on the default temp dir of your server. From there you have to copy it to the dir you want it to go.
The only strange thing I see is that you use a closing quote in the FORM definition, which is not opened?!
<FORM ACTION="upload.phtml" METHOD=POST ENCTYPE=multipart/form-data"> <---
Does this give the trouble, so that no file is sent?
Peter
|

April 5th, 2000, 05:27 AM
|
|
Contributing User
|
|
Join Date: Mar 2000
Location: Hong Kong
Posts: 73
Time spent in forums: 6 h 31 m 9 sec
Reputation Power: 14
|
|
Thanks PAV
Yeah, the missing " was the problem!
damn, i wasted 2 days time on such matter.
ahhh
hehe
thanks anyway.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|