PHP upload problem

Hi,
I create a simple code to upload file using php code.


index.php

<?php
@ini_set('upload_max_filesize', '1024000000000M');
@ini_set('post_max_size', '1024000000000M');
@ini_set('max_input_time', 3600000000000);
@ini_set('max_execution_time', 3600000000000);
?>
<!doctype html>
<head>
<title>Proalbum: File Upload </title>
<style>
body { padding: 30px }
form { display: block; margin: 20px auto; background: #87bb2f; border-radius: 10px; padding: 15px }

.progress { position:relative; width:400px; border: 1px solid #ddd; padding: 1px; border-radius: 3px; background:#FF0000;}
.bar { background-color:#87bb2f; width:0%; height:20px; border-radius: 3px;  }
.percent { position:absolute; display:inline-block; top:3px; left:48%; }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <h1>Select a File to Upload</h1>
        <form action="video_upload.php" method="post" enctype="multipart/form-data">
        <input type="file" name="uploadedfile"><br>
        <input type="submit" value="Upload File">
        <input type="hidden" name="MAX_FILE_SIZE" value="99999999"/>
    </form>

    <div class="progress">
        <div class="bar"></div >
        <div class="percent">0%</div >
    </div>

    <div id="status"></div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
(function() {

var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');

$('form').ajaxForm({
    beforeSend: function() {
        status.empty();
        var percentVal = '0%';
        bar.width(percentVal)
        percent.html(percentVal);
    },
    uploadProgress: function(event, position, total, percentComplete) {
        var percentVal = percentComplete + '%';
        bar.width(percentVal)
        percent.html(percentVal);
    },
    complete: function(xhr) {
        bar.width("100%");
        percent.html("100%");
        status.html(xhr.responseText);
    }
});

})();
</script>

</body>
</html>

video_upload.php

<?php
@ini_set('upload_max_filesize', '1024000000000M');
@ini_set('post_max_size', '1024000000000M');
@ini_set('max_input_time', 3600000000000);
@ini_set('max_execution_time', 3600000000000);
//$upload_dir = $_SERVER['DOCUMENT_ROOT'] .  dirname($_SERVER['PHP_SELF']);
$upload_dir='rajesh';
$upload_url = '/';

	$temp_name = $_FILES['uploadedfile']['tmp_name'];
	$file_name = $_FILES['uploadedfile']['name'];
			
	$file_path = $upload_dir.$upload_url.$file_name;
	
	
	if(move_uploaded_file($temp_name, $file_path))
	{
		echo "File uploaded Success !";
	}

?>

and
php.ini
max_execution_time: 3600000000000
max_input_time 3600000000000
post_max_size 1024000000000M
upload_max_filesize 1024000000000M

and in .htaccess file
php_value max_execution_time 3600000
php_value max_input_time 3600000
php_value post_max_size 1024000M
php_value upload_max_filesize 1024000M

But still can’t able to upload file more than 20 mb.
Can anyone please help me in this.
Thanks

What is the error you are getting, or are you even getting one?

Also, did you restart Apache?

Hi,
This is the error,

500 Server Error
A misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again.
Thanks

Are those maximum sizes a bit too big? 1,024,000,000,000M sounds very big - there is a note about not exceeding the 32bit integer limit if you’re on a 32bit server. If you set it to, say, 32M, does it make any difference?

Or, have you checked (if you can) the server logs in case they shed any light?

Hi,
I have change it to 32M and 128M (maximum) but still no luck.
And there is no error message i am able to find in my server log (error log).

Thanks

rkrathor, sorry to be a little blunt on this one, but we need more work done on your side in order to provide us with useful info to help you out. All you need to figure this one out is a little more time breaking down this problem into parts where it could possible break.

Before coming back with some more info for us, try the following:

  1. reset your apache settings to default
  2. create a new php file that has no ajax request, just a plain old form that will upload a file, and on the same file, print the file from $_POST if it exists.
  3. test a small file, does it work?
  4. post your regular file, does it work?
  5. go back to your current page and test, what happens this time?

hi,
I have change the php.ini from 5.2 to 5.4 and change display error on
then i am getting this error.

Notice: Undefined index: uploadedfile in /home1/proalbu1/public_html/file-upload-progress-bar/video_upload.php on line 14

this is the line no 14 contains
$temp_name = $_FILES[‘uploadedfile’][‘tmp_name’];

Can you please suggest what to do now?

Thanks

Can you add


var_dump($_FILES);

just after you set $upload_url and post the response please? Also if the file has not uploaded, then the array elements will be undefined. As Kyle said, you need to start breaking this down into smaller sections to debug it.

Hi droopsnoot ,
Is your answer for Undefined index: then it is solved now by simply increasing the size in php.ini.
but the main 500 server error still coming.
Thanks

Yes, it was for the undefined index. Can’t help on the 500 error, sorry.