PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 28, 2022

[FIXED] codeigniter file upload - optional?

 January 28, 2022     codeigniter, file, upload     No comments   

Issue

I'm sure this is simple but I can't see how to make uploading a file with CI optional.

If you leave the file input box empty, the error "You didn't choose an upload file" appears.

The reason I want it to be optional is that my form edits a directory type listing, and I don't need to upload the image each time I edit the listing.

Is there a way to remove the "required" error handling on the file class


Solution

Use the following:

<?php if ( $_FILES AND $_FILES['field_name']['name'] ) 
{
    // Upload the file
}


Answered By - user290102
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing