Unable to upload video to localhost - php

I work in a PHP - HTML project, and I want to upload some files into a directory. The problem is that the code works fine, and I checked it for *.doc, *pdf, *.txt file types. However, I need to upload videos as well. When I try to do so, the upload is unsuccessful. What can I do? Is is a matter of file size? I tried to upload videos of size about 5Mb and the problem remains: After using var_dump() I understood that in the nextForm the $_POST['submit'] condition is false.
<form action='nextForm.php' method = 'post' enctype= 'multipart/form-data' >
file: <input type='file' name = 'upload' >
<p> <br> </p>
<input type='submit' name = 'submit' value ='upload it!' >
</form>

You need to set the value of upload_max_filesize and post_max_size in your php.ini .
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

Related

Can't upload audio file with PHP5.5.12 on WampServer 2.5

I have a problem with upload mode in PHP. Can you help me ?
My form in HTML:
<form action="upload_file.php" enctype="multipart/form-data" method="post">
<input type="file" name="file">
<input type="submit" value="ok">
</form>
My PHP code in 'upload_file.php':
<?php
if (!isset($_FILES['file'])){
echo "Failed";
}
else{
echo "All Ok";
}
?>
When I select image, text, zip, rar ... It report "All Ok". But, If I select audio or video, it report "Failed". So I can't upload audio file. What is wrong ? Thank you very much !.
Make sure that the size of your file does not exceed the limitations listed here (your php.ini file)
# The values are just for example!
; Maximum allowed size for uploaded files.
upload_max_filesize = 3M
; Must be greater than or equal to upload_max_filesize
post_max_size = 3M

Getting $_FILES array empty for some specific image files

I've following HTML code to upload image file :
<form id="request_form" method="post" enctype="multipart/form-data" action="print.php">
<input type="file" name="student_image" id="student_image" accept="image/*" capture/>
<button type="submit">Submit</button>
</form>
PHP code is as follows :
<?php
print_r($_FILES);// Here I'm getting blank $_FILES array for few specific image files which are greater than 10 MB in size
?>
Following are the file upload setting from my php.ini file:
upload_max_filesize = 10M
post_max_size = 10M
I'm getting the blank array when I try to upload image files which are greater than 10 MB in size.
Please help me out from this issue.
You need to change your php.ini file and set greater value than 10M, it is config for Apache, and Apache doesn't let you to send big image and files before it

WAMP max_upload_filesize

I am writing a PHP script to upload and re-size 4 images.
I have opted to use the method of giving 4 inputs the same name (an array):
<input type="file" name = "userfile[]" id="file1" />
<input type="file" name = "userfile[]" id="file2" />
<input type="file" name = "userfile[]" id="file3" />
<input type="file" name = "userfile[]" id="file4" />
I have set max_upload_filesize in wamp to 50M.
I have verified the max_uploads is set to default (20).
I have restarted all services and run php_info to verify this php.ini file was loaded.
My form-receiver page only does one thing:
var_dump($_FILES["userfile"]);
This works well, until file size approaches 8MB.
When the size of the uploaded files approache 8MB I get the error
Notice: Undefined index: userfile in C:\wamp\www\uploader\file_upload.php on line 2
I have re-sized one image, pushing it up to 8MB size, and then tried ot upload 1 single file- this recreates the error. I am certain that an 8MB limit exists here.
Can anyone help me solve this?
Find post_max_size and increase it's value.
Also, it's upload_max_filesize, not max_upload_filesize.

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!
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
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.

larger file upload problem with php

I need to upload a csv file to a server. works fine for smaller files but when the file is 3-6 meg its not working.
$allowedExtensions = array("csv");
foreach ($_FILES as $file) {
if ($file['tmp_name'] > '') {
if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) {
die($file['name'].' is an invalid file type!<br/>'. ''. '<&lt Go Back');
}
if (move_uploaded_file($file['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo "File has been uploaded";
}
//upload form
<form name="upload" enctype="multipart/form-data" action="<? echo $_SERVER['php_self'];?>?action=upload_process" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="31457280" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
I have also added this to htaccess
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200
Where am i going wrong?
What is the value of $_FILES['userfile']['error']? Have a look here:
http://php.net/manual/en/features.file-upload.errors.php
Also, whats with this:
if ($file['tmp_name'] > '') {
I don't think that's very healthy.
Just some suggestions to your code
($file['tmp_name'] > '') should be something like ( ! empty($file['tmp_name']))
echoing "possible file upload attack" won't help anyone. If you believe it is a possible attack, log it to a file.
The form action attribute, the $_SERVER['php_self'] should be capitalised because it is a constant, i.e. $_SERVER['PHP_SELF'].
Check your apache error logs and the error should be there?
Check your php.ini file and see if upload_max_filesize in there is set higher than 3 MB, I don't know if the .htaccess has precedence over the php.ini.
The default upload limit on debian php5 is 2MB if I recall correctly, but I am not sure what system you are running on.
You can also check the php values if you create a file e.g. info.php and put it in the same directory as your "problem php script".
The file content should look like this
<?php
phpinfo();
?>
This will give you all php relevant values referring to the directory you are in, hope it helps.

Categories