#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Hderabad,Andhra Pradesh,India
    Posts
    10
    Rep Power
    0
    hello,
    i tried the foll code for file upload given
    in professional php programming, Wrox Pub.

    upload.php
    ----------
    <?
    print "original file ".$userfile_name;
    if (copy($userfile,"C:upload.txt"))
    {
    echo("<b>file success </b>");
    }
    else
    {
    echo ("<b> Error: fail to copy
    file..</b>");
    }
    unlink($userfile);
    ?>
    upload.htm
    ----------
    <html>
    <head>
    <title>Untitled</title>
    </head>

    <body>
    <form action="upload.php" method=post enctype="multipart/form-data">
    Submit this file : <input type=file name="userfile"><br>
    <input type=submit><br>
    </form>
    </body>
    </html>

    i tried to upload a file c:testBB.txt

    the following error occured :

    original file BB.txt

    Warning: Unable to open 'php27' for reading: No such file or directory in Dhplearnupload.php on line 4
    Error: fail to copy file..
    Warning: Unlink failed (No such file or directory) in Dhplearnupload.php on line 12

    what could be the problem

    any help would be much appreciated

    thank u
    anitha
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    Change the <FORM> method to PUT.

    ------------------
    To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    I have enever heard of a form method put, but then again there is a lot I haven't heard of! Usually I set a variable for my upload path

    like
    $upload_path = "C:uploads".$userfile_name;
    if (copy($userfile,$upload_path)) {
    print "file uploaded";
    }
    else {
    print "error";
    }
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Hderabad,Andhra Pradesh,India
    Posts
    10
    Rep Power
    0
    hello homer,
    i changed the <form> method to PUT
    but i got a similar error..given below

    original file
    Warning: Unable to open 'CintuBB.txt' for reading: No such file or directory in Dhplearnupload.php on line 5
    Error: fail to copy file..
    Warning: Unlink failed (No such file or directory) in Dhplearnupload.php on line 13


    please help

    thank u
    anitha
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Hderabad,Andhra Pradesh,India
    Posts
    10
    Rep Power
    0
    hello homer,
    i changed the <form> method to PUT
    but i got a similar error..given below

    original file
    Warning: Unable to open 'CintuBB.txt' for reading: No such file or directory in Dhplearnupload.php on line 5
    Error: fail to copy file..
    Warning: Unlink failed (No such file or directory) in Dhplearnupload.php on line 13


    please help

    thank u
    anitha
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Ontario, Canada
    Posts
    498
    Rep Power
    18
    My mistake, you need to mock up your .htaccess and/or httpd.conf for PUT support... anyways, try this out:

    <form method="POST" action="upload.php" enctype="multipart/form-data">
    <input name="filename" type="file">
    <input type="submit">
    </form>

    and in your upload.php, have this:

    <?php
    if (copy($filename,$DOCUMENT_ROOT.$filename)) {
    echo "Success!";
    } else {
    echo "Failure.";
    ?>

    And after that, your uploads should work fine.

    ------------------
    To alcohol! The cause of, and solution to, all of life's problems. -- Homer Simpson

    [This message has been edited by cka (edited September 03, 2000).]
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Hderabad,Andhra Pradesh,India
    Posts
    10
    Rep Power
    0
    hi homer
    i am sorry to say it didn't work again
    it gave the same warning.

    Warning: Unable to open 'php2' for reading: No such file or directory in Dhplearnupload.php on line 4
    Error: fail to copy file..
    Warning: Unlink failed (No such file or directory) in Dhplearnupload.php on line 12

    what could be the problem?

    thank u
    anitha

  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Hderabad,Andhra Pradesh,India
    Posts
    10
    Rep Power
    0
    hi homer
    i am sorry to say it didn't work again
    it gave the same warning.

    Warning: Unable to open 'php2' for reading: No such file or directory in Dhplearnupload.php on line 4
    Error: fail to copy file..
    Warning: Unlink failed (No such file or directory) in Dhplearnupload.php on line 12

    what could be the problem?

    thank u
    anitha

  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Hderabad,Andhra Pradesh,India
    Posts
    10
    Rep Power
    0
    hi homer
    i am sorry to say it didn't work again
    it gave the same warning.

    Warning: Unable to open 'php2' for reading: No such file or directory in Dhplearnupload.php on line 4
    Error: fail to copy file..
    Warning: Unlink failed (No such file or directory) in Dhplearnupload.php on line 12

    what could be the problem?

    thank u
    anitha

  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Malaysia
    Posts
    5
    Rep Power
    0
    Greetings,

    Use stripslashes() commands.

    if (copy(stripslashes($userfile),"C:upload.txt"));




Similar Threads

  1. Replies: 1
    Last Post: February 8th, 2004, 01:59 PM
  2. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 07:42 PM
  3. how to upload text file into blob field
    By misoz in forum MySQL Help
    Replies: 8
    Last Post: February 5th, 2004, 02:48 AM
  4. file upload problem
    By user# 63632 in forum PHP Development
    Replies: 4
    Last Post: February 1st, 2004, 12:41 AM
  5. php-sql file upload and download
    By mthroesch in forum PHP Development
    Replies: 0
    Last Post: January 28th, 2004, 01:56 AM

IMN logo majestic logo threadwatch logo seochat tools logo