How can I know why pictures not uploading in codeigniter form

Viewed 58

I created a website using Codeigniter and mysql. There is a form for users where they upload their pictures. When I upload a picture to test it, it works fine. But sometimes, when someone else uploads a picture, it doesn't work. How can I know the actual problem?

2 Answers

There are many ways to debug a file upload issue. Most certain checks to implement in code are:

  1. Filesize - If media file size is more than the defined size, It should throw some message to the user.
  2. Extensions - Do list accepted extensions as a text message around file upload button. In the code, make sure, your code accepts those extensions.
  3. Log errors and warnings - Enable log errors. You can easily debug the issue.
  4. Make sure the directory where files will upload must have writable permissions.
  5. On the webpage where the image will be displayed,it must have a proper path like https://www.DOMAINNAME.com/directoryName/fileName.extension

You can check in php.ini file for following directives:

upload_max_filesize & post_max_size

If there is low upload_max_filesize or post_max_size is set it will not upload files.

You can verify both values in using phpinfo(); method

Related