|
-
Sep 15th, 2007, 03:36 AM
#1
Thread Starter
New Member
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 ?
-
Sep 15th, 2007, 07:50 PM
#2
Stuck in the 80s
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.
-
Sep 16th, 2007, 05:15 PM
#3
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
-
Sep 16th, 2007, 05:26 PM
#4
Stuck in the 80s
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!"?
-
Sep 16th, 2007, 05:54 PM
#5
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
-
Sep 16th, 2007, 05:56 PM
#6
Stuck in the 80s
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.
-
Sep 16th, 2007, 06:29 PM
#7
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
-
Sep 16th, 2007, 06:37 PM
#8
Stuck in the 80s
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
-
Sep 16th, 2007, 06:41 PM
#9
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
-
Sep 18th, 2007, 08:34 AM
#10
Thread Starter
New Member
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.
-
Sep 18th, 2007, 04:30 PM
#11
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
-
Sep 18th, 2007, 09:04 PM
#12
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|