#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Hong Kong
    Posts
    73
    Rep Power
    15
    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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    15
    <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
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Hong Kong
    Posts
    73
    Rep Power
    15
    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    15
    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
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Hong Kong
    Posts
    24
    Rep 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....
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    15
    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
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Hong Kong
    Posts
    73
    Rep Power
    15
    Thanks PAV

    Yeah, the missing " was the problem!
    damn, i wasted 2 days time on such matter.
    ahhh
    hehe
    thanks anyway.

Similar Threads

  1. flash to upload files to a server?
    By madskater212 in forum Flash Help
    Replies: 1
    Last Post: February 10th, 2004, 07:14 AM
  2. Replies: 1
    Last Post: February 8th, 2004, 02:59 PM
  3. Giving error when trying to upload huge files
    By chandar in forum PHP Development
    Replies: 1
    Last Post: January 17th, 2004, 06:56 AM
  4. file upload - image files ONLY
    By zyxep in forum PHP Development
    Replies: 3
    Last Post: December 12th, 2003, 05:56 PM

IMN logo majestic logo threadwatch logo seochat tools logo