You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by David Kenzik <da...@kenzik.com> on 2000/10/05 19:16:04 UTC

File Upload Issue

I apologize if this has been covered, but I wasn't able to locate anything
explicit in the archives pertaining to my situation.

I'm using Apache::Request 1.31 to handle file uploads, which work just fine.

I can upload all day.

I'm also using the apr->parse method to grab status on the upload candidate
to determine if the file size is greater than POST_MAX. This works fine--
libapreq knows that the file is too large and reports it via apr->notes.

However, when using the result of apr->parse as a conditional to determine
if I should let the file be uploaded, I run into a snag:

An example snippet:

	my $status=$apr->parse;
	$r->log_reason("Status is: " . $arp->notes('error-notes'));
	if ($status) {
		$r->send_http_header;
		$r->print("File upload error");
		return OK;
	}

I expect this to immediately return to the client the error message and
close the connection. Is that the wrong expectation?

What really happens is the logging occurs and then the client uploads the
file before the message is displayed.

Am I missing something? Or is there another method to trap the conditions I
want to impose on a file upload?

The problem happens in the following environment, everything compiled from
source:

	Apache 1.3.12
	mod_perl 1.24
	libapreq 1.31 w/ and w/o patch from joe@sunstarsys.com 6/30/2000
	Linux 2.2.16
	Perl 5.005_03

I would use CGI for the uploading as recommended in the guide, but my
handler is doing much more than just uploading, including custom auth.

Any assistance would be appreciated.

-- 
David S. Kenzik
david@kenzik.com - http://kenzik.com
Original Music - http://mp3.com/text

Re: File Upload Issue

Posted by Vivek Khera <kh...@kciLink.com>.
>>>>> "DK" == David Kenzik <da...@kenzik.com> writes:

DK> I expect this to immediately return to the client the error message and
DK> close the connection. Is that the wrong expectation?

Yes.

DK> What really happens is the logging occurs and then the client uploads the
DK> file before the message is displayed.

Think about how HTTP works, especially about when exactly your code
will get executed.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.                Khera Communications, Inc.
Internet: khera@kciLink.com       Rockville, MD       +1-301-545-6996
GPG & MIME spoken here            http://www.khera.org/~vivek/