Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Empty file input cause upload error
  • Hi guys

    I have a small issue on some user form. I dont know if I miss something but when you validate the form without uploading an (optionnal) picture, my upload script (which is really close of the one in the doc) get_errors method return the #4 error "No file was uploaded". Is this a normal bevahior ? Do I have to check for an uploaded file before I call that upload function ? And if yes what's the more elegant way to do this ?

    If I ask, its because I dont remember having this bevahior with others fuel apps.

    Thanks
  • HarroHarro
    Accepted Answer
    That error is generated by the upload class, when you ask it to process uploaded files, but $_FILES is empty.

    So if your file upload is optional, you need to check if there is a file before you ask Upload to process it.

    Alternatively, put the Upload method call in a try/catch block, and catch \Fuel\Upload\NoFilesException to suppress the exception.
  • Thats all what I needed. Thanks once again ;)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion