Jump to content

PHP upload problem.


rajeshkr

Recommended Posts

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

Link to comment
Share on other sites

Do you have control over the web server's (Apache?) configuration file? If so, study the LimitRequestBody parameter.

 

Be aware that too many players in this process hold filesizes and limits in an integer field. So some of these (ridiculously large) limuts will be ignored because they are greater than what a 32-bit integer can hold.

Edited by bsmither
Link to comment
Share on other sites

1 - I wonder why you suppress the outcome of your ini-set statements?  What are you hiding from yourself / the user?  If anything, during development you WANT to see if there is an unexpected outcome, no?

 

2 - this line:

 

ini_set('upload_max_filesize', '1024000000000M'); 

is asking for an inordinately HUGE filesize.  The M indicates megabytes already, so why so many zeros?  Don't you just want

 

ini_set('upload_max_filesize', '20M');   

I wonder if #1 is preventing you from seeing an error message caused by #2? 

Link to comment
Share on other sites

Do you have control over the web server's (Apache?) configuration file? If so, study the LimitRequestBody parameter.

 

Be aware that too many players in this process hold filesizes and limits in an integer field. So some of these (ridiculously large) limuts will be ignored because they are greater than what a 32-bit integer can hold.

Can you please tell me what is the name of that file, i have access to my control panel. and as i said i have changed my php.ini file as said in forums and where i search for solution but still no luck.

Thanks

Link to comment
Share on other sites

1 - I wonder why you suppress the outcome of your ini-set statements?  What are you hiding from yourself / the user?  If anything, during development you WANT to see if there is an unexpected outcome, no?

 

2 - this line:

ini_set('upload_max_filesize', '1024000000000M'); 

is asking for an inordinately HUGE filesize.  The M indicates megabytes already, so why so many zeros?  Don't you just want

ini_set('upload_max_filesize', '20M');   

I wonder if #1 is preventing you from seeing an error message caused by #2? 

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. 

​secondly 

I want to upload between 300 MB to 500 MB file. not 20 MB. its was just to give maximum file size that's why so many zeros , i put there.

 

Thanks

Link to comment
Share on other sites

 

I want to upload between 300 MB to 500 MB file. not 20 MB. its was just to give maximum file size that's why so many zeros , i put there.

You need to send the file or a group of large files "chunking" uploads into small pieces of data and send it to the file server via ajax methods. Plupload and others similar JS libraries can do that for you.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

If you look at the manual under $_FILES there is a user-added note concerning exactly this issue.  Apparently you haven't provided a file to be uploaded, so the FILEs array isn't created.

Hi ginerjm,

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.