Results 1 to 12 of 12

Thread: Upload files with progress status

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    2

    Talking Upload files with progress status

    Hi, can you help me, please ?
    I need create PHP upload with progress status. I used function move_uploaded_files and it was OK. But when I'm uploading the large files, it takes a much of time. Can you help me ?

    How I show upload status ?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Upload files with progress status

    http://swfupload.mammon.se/

    This uses Flash to upload the file, but you can customize it to look and do anything you want -- the downside being that it requires Flash.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Upload files with progress status

    hey Hobo,

    I have been looking for something like that for a long time. I got it all set up to work, but it doesnt actually upload the files. Here is my php code:

    PHP Code:
    <?php
        session_start
    ();

        if(!empty(
    $_FILES["magfile"])) {
            
    $uploaddir "uploads";
            
    //Copy the file to some permanent location
            
    if(move_uploaded_file($_FILES["magfile"]["tmp_name"], $uploaddir)) {
                echo 
    "Uploaded!";
            } else {
                echo 
    "There was a problem Uploading!.";
            }
        }
    ?>
    My usual boring signature: Something

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Upload files with progress status

    Is magfile the actually name of your file field? It looks like you copied that PHP code straight from a comment in the PHP manual.

    Also, $_FILES[ "field_name" ] is an array, and it will never be empty (it will always have name, tmp_name, etc). Do this instead:

    PHP Code:
    if( !empty( $_FILES"magfile" ][ "tmp_name" ] ) ) 
    What is the output? Does it tell you "There was a problem Uploading!"?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Upload files with progress status

    yeah, i noticed that after i posted it. I changed it to what it should be "Filedata" and it still doesnt work.
    My usual boring signature: Something

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Upload files with progress status

    Do you have:

    Code:
    enctype="multipart/form-data
    On your form?

    Otherwise, please post the snippet of code for your HTML form.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Upload files with progress status

    here is the HTML:

    HTML Code:
    <form id="form1" action="index.php" method="post" enctype="multipart/form-data">
    		<div class="content">
    			<table>
    				<tr valign="top">
    					<td>
    						<div id="flashUI1" style="display: none;">
    							<fieldset class="flash" id="fsUploadProgress1">
    								<legend>Large File Upload Site</legend>
    							</fieldset>
    							<div>
    								<input type="button" value="Upload file (Max 100 MB)" onclick="upload1.browse()" style="font-size: 8pt;" />
    								<input id="btnCancel1" type="button" value="Cancel Uploads" onclick="upload1.cancelQueue();" disabled="disabled" style="font-size: 8pt;" /><br />
    							</div>
    						</div>
    						<div id="degradedUI1">
    							<fieldset>
    								<legend>Large File Upload Site</legend>
    								<input type="file" name="anyfile1" /> (Any file, Max 100 MB)<br/>
    							</fieldset>
    							<div>
    								<input type="submit" value="Submit Files" />
    							</div>
    						</div>
    					</td>
    				</tr>
    			</table>
    		</div>
    	</form>
    My usual boring signature: Something

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Upload files with progress status

    Ah, the file isn't coming from the HTML form, it's coming from the flash object -- it's been awhile since I've used it, I don't remember what the name of the field is.

    And it's hard to debug since it's all done via Flash.

    Try doing (assuming a file called debug.txt exists with correct permissions):

    PHP Code:
    file_put_contents"debug.txt"print_r$_FILES ) ); ?> 
    And seeing what fields are being sent
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Upload files with progress status

    here is the HTML:

    HTML Code:
    <form id="form1" action="index.php" method="post" enctype="multipart/form-data">
    		<div class="content">
    			<table>
    				<tr valign="top">
    					<td>
    						<div id="flashUI1" style="display: none;">
    							<fieldset class="flash" id="fsUploadProgress1">
    								<legend>Large File Upload Site</legend>
    							</fieldset>
    							<div>
    								<input type="button" value="Upload file (Max 100 MB)" onclick="upload1.browse()" style="font-size: 8pt;" />
    								<input id="btnCancel1" type="button" value="Cancel Uploads" onclick="upload1.cancelQueue();" disabled="disabled" style="font-size: 8pt;" /><br />
    							</div>
    						</div>
    						<div id="degradedUI1">
    							<fieldset>
    								<legend>Large File Upload Site</legend>
    								<input type="file" name="anyfile1" /> (Any file, Max 100 MB)<br/>
    							</fieldset>
    							<div>
    								<input type="submit" value="Submit Files" />
    							</div>
    						</div>
    					</td>
    				</tr>
    			</table>
    		</div>
    	</form>
    My usual boring signature: Something

  10. #10

    Thread Starter
    New Member
    Join Date
    Sep 2007
    Posts
    2

    Arrow Re: Upload files with progress status

    Thank you, but I need to get a progress of upload. How many % is uploaded (in Timer) and how long takes it of time.

  11. #11
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Upload files with progress status

    there is no way to tell that in php. there are no controls (like a timer) in php
    My usual boring signature: Something

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Upload files with progress status

    It's a client side operation. You might be able to do it in JavaScript by sending the form using the XmlHttpRequest object, although I have no idea how.

Posting Permissions

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



Click Here to Expand Forum to Full Width