On Sun, 2004-01-04 at 16:39, Vinod Kurup wrote:
> I'm trying to upload a 2.5 MB file to AOLserver 4 (downloaded from the
> SourceForge page). OS=Debian Linux.
>
> When I click 'Upload' on my form, the browser spins for a while, but my
> ACTION page never gets loaded and the browser eventually reports a
> 'Document contained no data' or 'Error loading page'. I've tried
> multiple browsers (IE, Mozilla, Safari). My file doesn't get uploaded
> and no errors occur in the error log.
>
> I'm using the sample-config.tcl file, except that I set EnableTclPages
> to true.
>
> Here's my form:
> ---------------
> <form method="POST" action="upload.tcl" enctype="multipart/form-data">
> <input type="file" name="upload_file">
> <input type="submit" value="Upload">
>
> Here's upload.tcl
> -----------------
> ns_cp [ns_queryget upload_file.tmpfile] "/home/vinod/test/[ns_queryget
> upload_file]"
> ns_returnredirect ./done.adp
>
> done.adp just does an ls on /home/vinod/test to show me it worked.
> Unfortunately, it never even seems to get to upload.tcl.
>
> It works perfectly on AOLserver 3.4.2.
> It doesn't work on AOLserver 3.5.6 or 4.0.
>
> Any ideas?

Using .tmpfile variable is a security risk. Here is a new way:

# 'uploaded_file' is the name of the file widget:
set original_file_var "uploaded_file"
set filename [ns_queryget $original_file_var]
set tmpfile [ns_getformfile $original_file_var]
set filesize [ns_conn filelength $original_file_var]
set headers [ns_conn fileheaders $original_file_var]
set content_type [ns_set iget $headers "content-type"]
set content_disposition [ns_set iget $headers "content-disposition"]

set backslash "\\"

# On windoze, the path is included, you have to remove it.
if {[set last_backslash [string last $backslash $filename]] > -1 } {
    set filename [string range $filename [expr $last_backslash + 1] end]
}

# Create path and use 'file copy' not ns_cp:
set path "/some/path"

file mkdir $path
file copy $tmpfile $path/$filename


tom jackson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of 
your email blank.

Reply via email to