473,685 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make file upload as fast as download, (no n00b)

dlite922
1,584 Recognized Expert Top Contributor
Before you jump in front of the train, no I don't mean ISP wise. I know providers throttle speed towards download.

This is in a two PC LAN and one user. one average PC is a RedHat 'LAMP' server and the other is an XP desktop.

The same file that is uploaded is downloaded much faster (ie 1 minutes to upload, 5 seconds to download)

Is it just how HTTP file uploads work? is it PHP? I've simplified my code to one file with one form and one move_uploaded_f ile() call. something that is completely stripped, if you insist, I'll give you the code.

To me it seems like it should be the same speed in this environment: same NIC speed, same LAN, similar processing power/hard drive speeds.

I'm looking mostly for an explanation because google results are infested with ISP related topics, which is not the case with me.

Thanks as always,




Dan
Jun 19 '09 #1
5 5866
Atli
5,058 Recognized Expert Expert
Hi.

I don't see why that would be either. A LAN connection is certainly capable of uploading at the same speed as downloading. (The distinction is only for our benefit. They are the same thing, really.)

I suppose it is possible that you PHP code, or some other software limitation on the receiving end (memory limits and such) are making it appear the upload is slower, while in reality it's just taking the server forever to process the file.
If your doing some sort of image processing, for instance, then that could take a while.

Other than that, I don't know. Maybe the browser your using is doing something to slow it down... validating the file before sending or something like that.

... I'm going to test this on my network, see it is is the same here.
Jun 19 '09 #2
Markus
6,050 Recognized Expert Expert
@Atli
Me too. ETA (report): 10 mins.
Jun 19 '09 #3
Atli
5,058 Recognized Expert Expert
I tried this on my local network.

Server is:
Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.2 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g Server at advefir-dev Port 80
Changed upload_max_file size and post_max_size to 500M, and the memory_limit to 128M.

Uploaded a 350Mb file in ~30 seconds.
Downloaded it in ~29 seconds.

Tried it several times. Always pretty much the same upload/download speeds.
Jun 19 '09 #4
dlite922
1,584 Recognized Expert Top Contributor
@Atli
WOW Atli! Thanks! That gives me some hope.

I'm not doing any processing and tried with IE6/GC/FF, except moving it from the PHP temp directory to the web folder where it can URL accessed.

I have Apache 2.2, PHP 5.1.6 Linux Redhat (9?) 2.6 kernel.

I'm going to do some more testing and see if I find the cause of my time difference.



Dan


PS: Someone else has a CMS with file uploading (on the same server). I tested it and got similar or longer results for upload and very quick download. so i don't think it's code but, Atli's test got me curious.
Jun 19 '09 #5
dlite922
1,584 Recognized Expert Top Contributor
TEST RESULTS:

3.2MB file took 63 seconds ^upload^ and 13 seconds to download.

Question remains: if it's my server, what's it doing?

I have a windows (WAMP) install at home, i'm going to run the following code at home as well and record the resullts.

test.php:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. /**
  4. * Test file upload and download speed, manually timeing it 
  5. */
  6. $destination = "/tmp/testFile.txt";  // where the file should be saved (apache must have access)
  7. $fileUploaded = false; // flag to display download button. 
  8.  
  9. // FIRST PAGE
  10. if($_POST['submit']) 
  11. {
  12.     move_uploaded_file($_FILES['testFile']['tmp_name'],$destination);
  13.     $uploadTook = round(microtime(true) - ($_POST['startUploadTS']/1000),5);
  14.     $fileUploaded = true; 
  15. }
  16.  
  17. // SECOND PAGE
  18. if($_POST['downloadFile']) 
  19. {
  20.     if(file_exists("/tmp/testFile.txt")) 
  21.     {
  22.         // commented out headers to output file to screen and not wait to open/save dialogue box. uncomment to see dialogue box. 
  23.         //        header('Content-Description: File Transfer');
  24.         //        header('Content-Type: application/octet-stream');
  25.         //        header('Content-Disposition: attachment; filename=test.txt');
  26.         //        header('Content-Transfer-Encoding: binary');
  27.         //        header('Expires: 0');
  28.         //        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  29.         //        header('Pragma: public');
  30.         //        header('Content-Length: ' . filesize($destination));
  31.         $begin = microtime(true); 
  32.         ob_clean();
  33.         flush();    
  34.           echo file_get_contents($destination); 
  35.           echo "<hr><br><br>Download took: ", round((microtime(true) - $begin),5), " MS"; 
  36.           exit(); 
  37.     }    
  38. }
  39.  
  40. ?>
  41. <html>
  42.     <body>
  43. <?php if ($fileUploaded) {?>
  44.  
  45.         <form name="global" id="global" action="" method="post" enctype="multipart/form-data">
  46.             <input type="submit" name="downloadFile" value="Click Here To Download File"><br />
  47.             Upload Took: <?php echo $uploadTook ?> MS
  48.         </form>
  49.  
  50. <?php } else { ?>
  51.  
  52.         <form name="global" id="global" action="" method="post" enctype="multipart/form-data">
  53.             <input type="hidden" name="startUploadTS" id="startTime" value="" />
  54.             <input type="file" name="testFile" id="testFile" /> 
  55.             <input type="submit" name="submit" value="Upload ^" onclick="document.getElementById('startTime').value = new Date().valueOf()" />
  56.         </form>
  57.  
  58. <?php } ?>
  59.     </body>
  60. </html> 
  61.  
  62.  

Feel free to run this on your *test* (not live) server as well.
Jun 19 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1033
by: Mike Moore | last post by:
Can anyone recommend an upload and download asp.net web control? Should allow the user to locate file on their hard drive and upload to web server and vice versa for download. It should also to the user the name of the file, length, and updated date. There should also be a maximum file limit to upload and download. Should also provide capability to upload and download multiple files.
1
2759
by: BW | last post by:
I am creating an upload/download function for an extranet site. Files will be uploaded to directory based upon the users login and associated project. The function works as long as I use "c:\Temp" as the directory. When I use any other hard coded directory or even Server.MapPath() the upload function fails and returns the error: "Exception has been thrown by the target of an invocation." Once I change the root directory to "c:\Temp",...
5
1765
by: Shawn H. Mesiatowsky | last post by:
I am creating an intranet App that is a document management system, and now I have been told they wan't the ebilty to version control directories, not just files. So I have the file upload and download working great, but I have no idea where to start on how to upload or download an entire directory, thankfully there will be no sub directories in the directories. Also, they do not want to select file by file because there may be 40 files in...
1
1270
by: mandlamuki | last post by:
Hi, I'm still learning PHP from scratch so please be patient with me. I have created a web site using html and PHP. I want to add a link that the users can click on so they can download a catalog and be able to save it to their computers. The catalog is a word document which has images. Please could you help me with some code
1
2542
by: jpandviv | last post by:
I'm looking to create an application which will allow me to upload a file using an encrypted/secure connection (SSL) and was looking to use the FileUpload control. This application will also allow my clients to download the file over the same https: site. Will both the file upload and download process be not only secured but encrypted as well? Are they're any do-able alternatives out there I can develop? Thanks, James
5
4721
by: John Devlon | last post by:
Hi, Some people like to go on vacation during christmas time, others try to do something they never did before.... I would like to create a multiple file upload page, with some nice progress bars.... You can buy ceveral components on the web but wheres the fun in that ? Creating a page that uploads multiple files, without the progress bar is not
2
1680
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I'm working with project in my company by using ASP.Net 2.0 that allow the users to upload and download files to web site in the internet as backup. The user will first upload his or her own files in the website that will save the data immediatlly into database. and when the user sign in into his or her account he can download his own files.
7
7589
by: rubelpasha | last post by:
How i can upload a ppt file and store it to some database and later download it. I have a code for uploading a txt file but id doesn't work. Plz help me in this regard. here is the code... <?php function upload_form(){ ?> <table border = "1" align="center"> <tr><td> <form method="post" enctype="multipart/form-data" action="<? echo $_SERVER?>">
0
1131
Manikgisl
by: Manikgisl | last post by:
HI!!, File Upload and Download using FTP C#.net We are very tired of Found out to Upload and Download
1
8761
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7589
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2938
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.