PHP File Upload Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Walsh

    #1

    PHP File Upload Problem

    I have a problem uploading files with PHP which has me stumped! I am unable
    to successfully upload files. My simple test script is as follows:

    <?php

    if (count($_FILES) )
    {
    var_dump($_FILE S) ;
    }

    if (is_uploaded_fi le($_FILES['toProcess']['tmp_name']))
    {
    print "<h3>File successfully upload.</h3>" ;
    print "<a href=\"{$_SERVE R['PHP_SELF']}\">Try again?<br>" ;
    }
    else
    {
    print <<< __RAWHTML__
    <form enctype="multip art/form-data" action="{$_SERV ER['PHP_SELF']}"
    method="post">
    <input type="hidden" name="MAX_FILE_ SIZE" value="10240000 ">
    Filename: <input name="toProcess " type="file">
    <input type="submit" value="upload">
    </form>
    __RAWHTML__;
    print "<br><a href=\"{$_SERVE R['PHP_SELF']}\">Try again?<br>" ;
    }

    ?>


    When I run it I get the following back:

    array(1) { ["toProcess"]=> array(5) { ["name"]=> string(12) "100_2038.J PG"
    ["type"]=> string(0) "" ["tmp_name"]=> string(0) "" ["error"]=> int(1)
    ["size"]=> int(0) } }

    Obviously I have some sort of error as my "tmp_name" key is null and the
    "error" key is 1.

    Any ideas or suggestions? I am running IIS with PHP 4.3.4. I checked my
    php.ini file and the settings for uploading files look good to me:

    ;;;;;;;;;;;;;;; ;
    ; File Uploads ;
    ;;;;;;;;;;;;;;; ;

    ; Whether to allow HTTP file uploads.
    file_uploads = On

    ; Temporary directory for HTTP uploaded files (will use system default if
    not
    ; specified).
    upload_tmp_dir = c:\windows\temp

    ; Maximum allowed size for uploaded files.
    upload_max_file size = 1G

    Thanks for any help or suggestions.

    Mike


    --
    Mike Walsh - mike_walsh at mindspring.com


  • Mike Walsh

    #2
    Re: PHP File Upload Problem


    "Mike Walsh" <mike_walsh@min dspring.com> wrote in message news:0%ald.9258

    [ ... snipped ... ][color=blue]
    >
    > ; Maximum allowed size for uploaded files.
    > upload_max_file size = 1G
    >[/color]

    [ ... snipped ... ]

    It turns out that 1G is not a valid value for this directive. Not sure why
    I haven't run into this problem previously but setting it to a "megabyte"
    value solves my problem.

    Mike

    --
    Mike Walsh - mike_walsh at mindspring.com


    Comment

    • John Dunlop

      #3
      Re: PHP File Upload Problem

      Since my server doesn't carry php.general I'm posting only
      to c.l.php.

      Mike Walsh wrote:
      [color=blue]
      > "Mike Walsh" <mike_walsh@min dspring.com> wrote[/color]
      [color=blue][color=green]
      > > upload_max_file size = 1G[/color]
      >
      > It turns out that 1G is not a valid value for this directive.[/color]

      Right. The shorthand notations are listed in PHP.net's FAQ
      as upper- or lowercase 'K' and 'M', where '1K' equals 1024
      bytes and '1M' equals 1048576 bytes. '1G' equals 1 byte!

      <http://www.php.net/manual/en/faq.using.php#f aq.using.shorth andbytes>
      [color=blue]
      > Not sure why I haven't run into this problem previously but
      > setting it to a "megabyte" value solves my problem.[/color]

      I don't see that unit listed anywhere; it isn't mentioned in
      the docs for file upload configuration options.

      PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


      HAGW!

      --
      Jock

      Comment

      • Mike Walsh

        #4
        Re: PHP File Upload Problem


        "John Dunlop" <usenet+2004@jo hn.dunlop.name> wrote in message
        [ ... snipped .. ]
        [color=blue][color=green]
        > > Not sure why I haven't run into this problem previously but
        > > setting it to a "megabyte" value solves my problem.[/color]
        >
        > I don't see that unit listed anywhere; it isn't mentioned in
        > the docs for file upload configuration options.
        >[/color]
        [ ... snipped ...]

        I should have been more clearer. I used the "M" notation to set my desired
        value in megabytes.

        Mike

        --
        Mike Walsh - mike_walsh at mindspring.com


        Comment

        Working...