What extensions are supported by $_FILES?

Asked

Viewed 44 times

1

In my system the user can include files within a comment. The problem is that some file extensions are giving error (for example gave error in an Excel spreadsheet).

I wonder if you have how to set up for it to save all types of files or if this is a limitation even and then I will create an error treatment due?

What I’ve already tried :

I searched the PHP documentation and right here on Stack Overflow but I found nothing about.

Note: I don’t need code only a clarification about the variable $_FILES.

  • 4

    And what was the mistake?

  • PHP does not limit any file, or extension, or mime type, "of course", after all a file is only information. You do the validation so that the user chooses the desired format. What must have happened is an error in your code, could show the code where the error is occurring?

  • 1

    @Stormwind has no configuration even in Apache stating what are the upload types? I thought it had

  • There are some directives that may prevent the upload @Jeffersonquesado

  • @Andersoncarloswoss one of the users who informed me about it, but did not see what error appeared , I am preparing a test and already put about

  • @Stormwind , no error message appeared the variable $_FILES simply returned ["error"]=> int(1) , I talked to my supervisor and he told me it was probably the file size , I believe that’s right because I tested with different files and it worked but I created a very large excel spreadsheet and it returned the ["error"]=> int(1) , I will make a bug treat for the size of the files , thanks to all

Show 1 more comment

1 answer

2


As already stated in the comment and can be seen in a reply on Stack Overflow, PHP does not limit any file, or extension, or mime type, "naturally", after all a file is only information. You do the validation so that the user chooses the desired format.

What happened was an error related to the size of upload, that exceeded the directives configured, as you said yourself. You can confirm what each returned code means this documentation link.

When you have the superglobal $_FILES['error'] with value 1, is written:

Value: 1; The uploaded file Exceeds the upload_max_filesize Directive in php.ini.

That in free translation would be:

Value: 1; The file loaded exceeds the directive upload_max_filesize in php.ini.

To make the change, go to php.ini and make changes as needed on this line, which controls the maximum size allowed for uploads:

upload_max_filesize = 40M

After modification of the file php.ini, you need to restart your HTTP server to use the new configuration.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.