Upload file that does not exist

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

    #1

    Upload file that does not exist

    I have a form:

    <form method="post" action="res_add aresource.php" name="frm1"
    enctype="multip art/form-data" onsubmit="retur n checkFields();" >

    with a file object:

    <input name="localfile " id="localfile" type="file" size="68">

    to upload a file.

    I click the Browse button and select a file on my hard disk. Then I
    delete or rename the file on my hard disk. When I then submit the
    form

    $uploaded = move_uploaded_f ile($_FILES['localfile']['tmp_name'],
    $uploadfile);

    returns true and $_FILES['userfile']['error'] does not return an error
    (it returns the empty string which I guess means 0).

    The only way to detect something fishy is going on is looking at
    $_FILES['localfile']['size'] that returns 0.

    Is this the way things are supposed to be? I would want $uploaded to
    be false.

    Regards,

    Jan Nordgreen

  • Rik Wasmus

    #2
    Re: Upload file that does not exist

    On Mon, 29 Oct 2007 21:52:25 +0100, damezumari <jannordgreen@g mail.com
    wrote:
    I have a form:
    >
    <form method="post" action="res_add aresource.php" name="frm1"
    enctype="multip art/form-data" onsubmit="retur n checkFields();" >
    >
    with a file object:
    >
    <input name="localfile " id="localfile" type="file" size="68">
    >
    to upload a file.
    >
    I click the Browse button and select a file on my hard disk. Then I
    delete or rename the file on my hard disk. When I then submit the
    form
    >
    $uploaded = move_uploaded_f ile($_FILES['localfile']['tmp_name'],
    $uploadfile);
    >
    returns true and $_FILES['userfile']['error'] does not return an error
    (it returns the empty string which I guess means 0).
    >
    The only way to detect something fishy is going on is looking at
    $_FILES['localfile']['size'] that returns 0.
    >
    Is this the way things are supposed to be? I would want $uploaded to
    be false.
    Well, the UA should issue the warning/block on a submit (Opera does BTW,
    with a nice inline explanation next to the input element, FF & MSIE
    don't). There's no way you can know it's not supposed to be an empty file,
    which it could be. Empty files are used quite regularly for genuine
    purposes.
    --
    Rik Wasmus

    Comment

    Working...