PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 3rd, 2000, 10:34 AM
ccm ccm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Hong Kong
Posts: 73 ccm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old April 4th, 2000, 03:12 AM
PAV PAV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Location: Netherlands
Posts: 77 PAV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #3  
Old April 4th, 2000, 03:21 AM
ccm ccm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Hong Kong
Posts: 73 ccm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #4  
Old April 4th, 2000, 09:45 AM
PAV PAV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Location: Netherlands
Posts: 77 PAV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #5  
Old April 4th, 2000, 08:09 PM
hkccm hkccm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Hong Kong
Posts: 24 hkccm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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....

Reply With Quote
  #6  
Old April 5th, 2000, 04:43 AM
PAV PAV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Location: Netherlands
Posts: 77 PAV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #7  
Old April 5th, 2000, 05:27 AM
ccm ccm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: Hong Kong
Posts: 73 ccm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Files Upload Help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap