473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

dlite922
1,584 Expert 1GB
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_file() 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 5840
Atli
5,058 Expert 4TB
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 Expert 4TB
@Atli
Me too. ETA (report): 10 mins.
Jun 19 '09 #3
Atli
5,058 Expert 4TB
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_filesize 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 Expert 1GB
@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 Expert 1GB
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
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...
1
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"...
5
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...
1
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...
1
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...
5
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...
2
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...
7
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...
0
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
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.