Jump to content

File upload file size 0


pavlosgr

Recommended Posts

Hello

 

I'm uploading a file and I want to detect when the uploaded file size is greater than the upload_max_filesize parameter of my server.

I tried to check the $_FILES['file']['size'] but I saw that it is filled with 0 when the uploaded file size is greater than the above parameter.

 

Is there any way to detect the uploaded file size in the above case?

I'm not really very keen on posting file size from the html form.

 

 

Thanks very much

Link to comment
https://forums.phpfreaks.com/topic/266271-file-upload-file-size-0/
Share on other sites

Yes I have

 

  <form action="upload_file.php" method="post"
    enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>

 

You need to test the ['error'] element - http://us2.php.net/manual/en/features.file-upload.errors.php

 

If($_FILES['file']['error'] === 0){ // test for exactly === a zero value
    // the file uploaded successfully and you can access the ['name'], ['type'], ['size'], and ['tmp_name'] elements
}

You need to test the ['error'] element - http://us2.php.net/manual/en/features.file-upload.errors.php

 

I am testing the ['error'] element and was getting an error code.

What I was looking for and didn't clear out in my question was how I'm sure that the code that I'm peeking

means file size exceeds server max file size.

 

 

 

But I had missed the above page which relates error code 1 with the error I was looking for.

 

 

Thank you all for your help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.