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 ? :wave:
Printable View
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 ? :wave:
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.
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!.";
}
}
?>
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:
What is the output? Does it tell you "There was a problem Uploading!"?PHP Code:if( !empty( $_FILES[ "magfile" ][ "tmp_name" ] ) )
yeah, i noticed that after i posted it. I changed it to what it should be "Filedata" and it still doesnt work.
Do you have:
On your form?Code:enctype="multipart/form-data
Otherwise, please post the snippet of code for your HTML form.
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>
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):
And seeing what fields are being sentPHP Code:file_put_contents( "debug.txt", print_r( $_FILES ) ); ?>
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>
Thank you, but I need to get a progress of upload. How many % is uploaded (in Timer) and how long takes it of time.:wave:
there is no way to tell that in php. there are no controls (like a timer) in php
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.