Very strange file upload behavior

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Very strange file upload behavior

    I tried to search for this issue on the group, but don't even know
    where to start, so here's my problem.

    We have a very simple form which has a file upload box.
    Upon submit the file should be uploaded (using the copy function, from
    the server's temp directory to our final directory), the database
    should be updated, and the user should be notified of success/failure.
    In that order. When we test it at the office, and even from a dial-up
    at home, everything is fine.

    When my client tries to do it from his cable modem connection here is
    what happens: He chooses the file on the form, clicks submit and the
    page churns away for a long while. Then, it just goes back to the form
    page. In the meantime, the file has been moved to the server's temp
    directory, but does not get to our final directory. The database gets
    updated (which should only happen after the copy function), but no
    confirmation message is given.

    Here is some truncated code:

    function upload_file()
    {
    global $target_dir,$target_file;
    $upload_temp = $_FILES['filename_new']['tmp_name'];
    $upload_file = $_FILES['filename_new']['name'];
    $target_dir = "../downloads";
    $target_file = $target_dir . "/" . $upload_file;

    if (!copy($upload_temp, $target_file))
    {
    echo "<h4>Failed to upload file...<h4><br>\n";
    die();
    }
    else
    {
    echo "<h4>Uploaded File Successfully...<h4><br>\n";
    return;
    }
    }
    upload_file();
    $sql = "INSERT INTO downloads
    (name,filename,sort_order,description,category,reg istration) VALUES
    ('".$name."','".$filename."',".$sort_order
    ..",'".$desc."',".$category.",".$registration.") ";

    $result = mysql_db_query($glb_db,$sql) or die(mysql_error());

    print "<p>The download has been added";
    Courtney L. Guest

  2. Similar Questions and Discussions

    1. strange behavior in File::Basename
      I'm using Perl 5.6.1 on Debian Linux 3.0 I noticed the module File::Basename doesn't behave like the shell commands basename/dirname in a special...
    2. Strange behavior when saving a file
      I'm using Illustrator 10.0.3, Mac OS 10.2.8. When I make changes to one of my Illustrator files and save it, it makes a copy of that file to the...
    3. #25784 [Opn->Bgs]: really strange problem with file upload
      ID: 25784 Updated by: sniper@php.net Reported By: kylewong at southa dot com -Status: Open +Status: ...
    4. #25784 [NEW]: really strange problem with file upload
      From: kylewong at southa dot com Operating system: Redhat 9 PHP version: 4.3.2 PHP Bug Type: HTTP related Bug description: ...
    5. Strange behavior after reading big file
      I have a piece of code that looks something like this: my %hash; my $i = 0; open HUGE, 'Huge_File' or die '>*choke*<'; $| = 1; print "\n"; for...
  3. #2

    Default Re: Very strange file upload behavior

    [email]possum_225@yahoo.com[/email] (Courtney L.) schrieb:
    > if (!copy($upload_temp, $target_file))
    Use move_uploaded_file() instead.

    Regards,
    Matthias
    Matthias Esken Guest

  4. #3

    Default Re: Very strange file upload behavior

    I'll give it a try right away. But can you help me understand the
    logic of why this is better?

    Matthias Esken <muelleimer2003nospam@usenetverwaltung.org> wrote in message news:<blhtlo.25o.1@usenet.esken.de>...
    > [email]possum_225@yahoo.com[/email] (Courtney L.) schrieb:
    >
    > > if (!copy($upload_temp, $target_file))
    >
    > Use move_uploaded_file() instead.
    >
    > Regards,
    > Matthias
    Courtney L. Guest

  5. #4

    Default Re: Very strange file upload behavior

    [email]possum_225@yahoo.com[/email] (Courtney L.) schrieb:
    > I'll give it a try right away. But can you help me understand the
    > logic of why this is better?
    Read the documentation at
    [url]http://de3.php.net/manual/en/function.move-uploaded-file.php[/url].

    Their english is much better than mine. :-)

    Regards,
    Matthias
    Matthias Esken Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139