#1
  1. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    Hello. I'm getting errors when trying to handle an uploaded file from a form.
    Here is the form:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <form name="form1" enctype="multipart/form-data" action = "file.php3" method=post>
    <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="10000"><input type="file" name="file_name">
    <input type="submit" name="Submit" value="Submit">
    </form>
    [/code]

    Here is the part of the file that processes the form:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?php
    echo "Processing File";
    printf("<br>Server side file name: %s", $userfile);
    printf("<br>Client side file name: %s", $userfile_name);
    $new_file = "images/" . $userfile_name;
    printf("<br>Destination file name: %s", $new_file);

    if (copy ($userfile, $destination))
    {
    echo "<br>File copy successful";
    }
    else
    {
    echo "<br>File copy failed.";
    }
    ?>
    [/code]

    None of the variables seem to be set on any of the printouts. They are all empty. I get an error saying that PHP cannot open file '', which means the variable is empty.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    Processing File
    Server side file name:
    Client side file name:
    Destination file name: images/
    Warning: Unable to open '' for reading: No such file or directory in /web/sites/sepodaticreations.com/docs/alabamahomes/file.php3 on line 15

    File copy failed.
    [/code]

    Any help is greatly appreciated.

    ---John Holmes
    --- www.SepodatiCreations.com
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    I just realized the within my copy statement I have $destination instead of $new_file. This is just a typo from trying different things to get this to work. I still get the same errors. Thanks.
  4. #3
  5. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    I think you need to use the fopen(), fwrite(), and fclose() functions.
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    I discovered the problem. Whatever you name the file input on the form is what you use for the variable names in the file processing script.

    <input type="file" name="WHATEVER">

    in the processing form
    $WHATEVER = server side file name
    $WHATEVER_name = client side file name

    ---John Holmes
    ---www.SepodatiCreations.com

Similar Threads

  1. Can't move or delete it!
    By Hykinsel007 in forum Windows Help
    Replies: 3
    Last Post: June 15th, 2004, 03:41 PM
  2. Uploaded files get 644 permision
    By bogaa in forum PHP Development
    Replies: 5
    Last Post: January 27th, 2004, 12:50 PM
  3. Previewing uploaded files before storing
    By rodina in forum PHP Development
    Replies: 0
    Last Post: January 15th, 2004, 01:33 AM
  4. How can I pack servlet files into a jar file?
    By suryahema in forum Java Help
    Replies: 1
    Last Post: December 18th, 2003, 08:32 AM
  5. file uploading.. 0 file(s) uploaded
    By zingzee in forum Java Help
    Replies: 1
    Last Post: December 16th, 2003, 08:51 AM

IMN logo majestic logo threadwatch logo seochat tools logo