Nicholas Corin
Nicholas Corin

Reputation: 2404

Problems with file uploading HTML5

I'm coding a web application and I need to be able to upload a CV. I have done my homework and tried everything I can find but I keep getting the same issue. In my PHP Script the $_FILES array is completely empty and the CV field is being sent to the $_POST array. My form big so I will just post the important code.

<form enctype="multipart/form-data" action="exec/register_user.php" method="post">
<input type="file" name="cv" id="cv"/>
<input type='submit' value='Register' />
</form>

Then I don't think it will help you with anything by posting the PHP code. But if i var_dump($GLOBALS), it shows that the $_FILES array is empty but 'cv' shows as a string in the $_POST array.

Any help will be appreciated. Thanks in advance!

Upvotes: 0

Views: 653

Answers (2)

Jon Grant
Jon Grant

Reputation: 11530

You are missing the hidden field max_file_size, required by PHP.

<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="20000000" />

See the explanation here.

Upvotes: 0

Anigel
Anigel

Reputation: 3437

This is normally caused by the uploaded file being too large and exceeding one of teh 2 defined upload limits. post_max_size or upload_max_filesize

You may be able to override these values in the .htaccess file if you have the right permissions to do so by adding teh following 2 lines.

php_value post_max_size 20M
php_value upload_max_filesize 20M

Would allow uploading of files upto 20 MB

Upvotes: 2

Related Questions