Uploads matters....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Emanuele D'Arrigo

    Uploads matters....

    Hi everybody!

    I could use a little explaination here!

    I spent quite a few hrs yesterday evening coding
    the script behind a form to upload a picture, and
    I think it does what it is supposed to do, but I'm
    not too happy with my understanding of the features
    available in php to deal with this issue.

    Question #1
    If the field in the form is not empty but the file
    does not exist on the client's hard drive, the variable
    $_FILES[filename][error] and $_FILES[filename][size]
    are both set to zero. But how do I discern between a
    file that is not existant and a transfer that for some
    strange reason has not yet written anything on the
    server side?

    Question #2
    Once the user click on the submit button, the transfer
    seems to start right away, and the next page is shown
    only when the transfer actually ends.
    Is there any way to avoid this? I'd like instead to
    show the first part of the page, wait for the transfer
    to finish, and only then continue with the generation
    of the rest of the page. Is this possible?

    Thanks for your help.

    Manu
  • Guest's Avatar

    #2
    Re: Uploads matters....


    "Emanuele D'Arrigo" <manu3d@mclink. it> wrote in message news:42485035.0 403180723.5c3ca 0d1@posting.goo gle.com...[color=blue]
    > Hi everybody!
    >
    > I could use a little explaination here![/color]

    The PHP script which receives the uploaded file should implement whatever logic is necessary for determining what should be done with the uploaded file. You can, for example, use the $_FILES['userfile']['size'] variable to throw away any files that are either too small or too big. You could use the $_FILES['userfile']['type'] variable to throw away any files that didn't match a certain type criteria. As of PHP 4.2.0, you could use $_FILES['userfile']['error'] and plan your logic according to the error codes. Whatever the logic, you should either delete the file from the temporary directory or move it elsewhere.

    If no file is selected for upload in your form, PHP will return $_FILES['userfile']['size'] as 0, and $_FILES['userfile']['tmp_name'] as none.

    The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

    _______________ _______________ ______
    Wil Moore III, MCP | Integrations Specialist | Assistant Webmaster


    Comment

    • Emanuele D'Arrigo

      #3
      Re: Uploads matters....

      Thanks Wil for your answer.

      Strangely, the $_FILES['filename']['tmp_name'] didn't seem to return "none",
      only an empty string instead. But I can handle that.

      Any hint about my second question?

      Manu

      Comment

      Working...