search

Home  >  Q&A  >  body text

php - Regarding the problem that file uploads are always overwritten after modifying the form

After uploading files through the form, I encountered this problem:

When submitting for the first time, any field can be fully saved.

But when I modify the form for the second time, the field of <input type="file"> is always automatically empty. How can I make the file type form have a value by default like the text type? After modification, Submission will not change

PHP中文网PHP中文网2785 days ago842

reply all(3)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:13:07

    The characteristic of the file control is that the user needs to manually select the file before the value will be available. It is recommended to give the file field a default value on the server side, or use js to determine whether the value of the file control is empty before submitting the front-end form. If it is empty, then Do not submit, prompt the user instead.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 13:13:07

    You can make a judgment in php, that is, when the file field is empty when modifying the form for the second time, you can make a judgment in php. If the file is empty, when updating the database data, the file field will not be updated. If If the submitted file is not empty, the file field is updated.

    reply
    0
  • PHPz

    PHPz2017-05-16 13:13:07

    The file is uploaded first using ajax. Just separate it from the handler

    reply
    0
  • Cancelreply