Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry PHP upload problem.

    Hi,
    I create a simple code to upload file using php code.
    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

  • #2
    Regular Coder Linux_Sage's Avatar
    Join Date
    Mar 2014
    Location
    Sterling,VA
    Posts
    105
    Thanks
    0
    Thanked 10 Times in 10 Posts
    Does it return any error messages? What is the current behavior?

  • #3
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Posts
    454
    Thanks
    0
    Thanked 20 Times in 20 Posts
    try removing this:
    <input type="hidden" name="MAX_FILE_SIZE" value="99999999"/>

    it might cause configs problem
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.

  • #6
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi c1lonewol,

    i have done as you said but still the problem persisting.
    Thanks

  • #7
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    do a var_export($_FILES); to see what variables it contains in the upload.

  • #8
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi Dubz,

    Where should i use this code, in first page the html page or in the php page where upload code is written.

    Quote Originally Posted by Dubz View Post
    do a var_export($_FILES); to see what variables it contains in the upload.
    thanks


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •