INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

input type='file'

input type='file'

(OP)
I am running the following simple HTML form to call the Perl script at the bottom of this post.
The script runs fine but depending on the size of the file selected to download, there is a delay before the text displays.
If I substitute the <input type='file'> command with a <input='text'> command, there is no delay.

The delay is more obvious on a slow internet connection which many of my clients have.

Could anyone suggest why there is such a long delay.

CODE --> HTML

<!DOCTYPE html>
<html>
<head>
<title>Upload Test</title>
</head>
<body>
<h1>File Upload Test</h1>
<FORM METHOD="POST" ACTION="cgi-bin/test2.pl" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="FILEID" VALUE="" SIZE=50 MAXLENGTH=80><BR>
<INPUT TYPE="hidden" NAME="call" VALUE="uploadimage">
<INPUT TYPE="submit" NAME="submit" VALUE="Upload File To Server"></FORM>
</body>
</html> 

CODE --> Perl

#!/usr/bin/perl
use strict;
use warnings;
print "Content-Type: text/html\n\n";
print "Start Script<br>";
print "This simple script only displays this text and performs no other function."; 

Keith
www.studiosoft.co.uk

RE: input type='file'

Do you have a URL that we can test against? Because " there is a delay before the text displays." is somewhat vague.

And what browsers have you tested with?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: input type='file'

(OP)
The following links to a basic form.
http://www.studiosoft.co.uk/uploadtest.htm
The form is submitted to a Perl script which does not process the upload but displays a text message.

If I submit the form without selecting an image, the script is called and text created by the script is displayed instantly.
If I select a file, there is a delay before the text generated by script is displayed.
The delay is proportional to the size of the selected file.

I have only tested it on various versions of IE.

Keith
www.studiosoft.co.uk

RE: input type='file'

Keith I tested your page and got the following

Quote:

Use caution on this site
www.studiosoft.co.uk
An unacceptable security risk is posed by this site.
McAfee Security Rating: Yellow


Powered By: SiteAdvisor Enterprise

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: input type='file'

(OP)
Not sure what that is about, it gets a clean bill of health from Google and Sucuri Site Checker.
Could it be complaining because there is a file upload script on there?

Keith
www.studiosoft.co.uk

RE: input type='file'

Quote:


If I select a file, there is a delay before the text generated by script is displayed.
The delay is proportional to the size of the selected file.

That would suggest that the delay is caused by the upload of the file. There really is nothing you can do if that is the case. If its a larger file it will taker longer to upload than a smaller file.

Do you need the file to be uploaded?

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: input type='file'

(OP)
The whole point of my question was that up until this point, the file has not been uploaded.
In the example above, a file name has been selected and then a script has been called, the upload has not taken place.

Keith
www.studiosoft.co.uk

RE: input type='file'

Quote:

In the example above, a file name has been selected and then a script has been called, the upload has not taken place.
That is not the case, file uploading (or downloading for that matter) over HTTP is a 'push' process,the client tells the server that there is 'X' number of bytes following, so the script will only run when the end of the form data is reached, so the upload HAS to take place before the server side processing starts.

Downloading is a 'push' of 'X' number of bytes to the client.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: input type='file'

The moment you submit the form, the upload will take place. At what other time would the file upload if not when the form is submitted?

Even if the file is not processed, it will have been uploaded to the server before your perl script runs.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: input type='file'

(OP)
Thanks both of you, that answers the question I have been asking for a while.
I always assumed that this code:-

CODE

while($bytesread=read($fileID,$buffer,1024)){
	print OPF "$buffer";
	$sum_bytes=$sum_bytes+1024;
} 
was responsible for the upload but from what I have learnt here, this only takes it from memory on the server and copies it to a file.
What happens in this process when very large files are uploaded?
How is it possible to implement a progress bar if the file is uploaded before the server side processing begins?

Keith
www.studiosoft.co.uk

RE: input type='file'

Its usually not possible. Most progress bars are done using Ajax techniques, or even flash based uploaders to upload files. But a standard form submission upload will not have a progress bar. Because there is no server side control of the upload until its completed, and no client side file control after the file has been chosen. Its all up to the browser at that point.

This is a security precaution, so the files variable cannot be altered by client side code, and the upload remains what the user selected, instead of an arbitrary chosen file path by some malicious client side code.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: input type='file'

(OP)
Thanks for clearing up that little mystery for me - I will stick with my animation while the files load.

Keith
www.studiosoft.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close