I tried your script on a couple of different test servers with no problems. I did not test the part that writes the file to a table, but the files written to the upload directory are identical to the ones sent by the browser. I tried all sorts of file types, including PDF, BMP, DOC and FWX.
Sent by Joe Goldsmith on 09/04/2003 09:28:26 PM:
Sure thing, thanks for asking. Here is the whole thing. IT seems to not upload some file types such as PDF or even FWX. At times it even fails on DOC or GIF/JPG. What I would like to have is a routine that uploads any file type. Perhaps this does and I just have an error but I tried to be faithful in recreating the example upload.fwx in this code. Any thoughts or ideas would be appreciated.
*** BEGIN SOURCE ***
LOCAL UPLOADNAME, UPLOADFILE, UPLOADTITLE, WHOLENAME, UPFILE
M.UPLOADNAME = ""
M.UPLOADFILE = ""
M.UPLOADTITLE = ""
M.WHOLENAME = ""
M.UPFILE = ""
IF Request.FormCount("btnchoice") > 0
M.UPLOADFILE = ALLTRIM(Request.Form('UPLOADFILE'))
M.UPLOADTITLE = ALLTRIM(Request.Form('UPLOADTITLE'))
*** SEND IT ***
FieldObject = Request.FormFieldObject("UPLOADFILE")
IF FieldObject.ContentLength > 0
FilePath = "..\upload\" + FieldObject.FileName
*** Get path and file name for storage ***
lcLen = LEN(filepath)
lcright = RIGHT(filepath,lclen-10)
lcfilepath = "upload/"+lcright
*** Open It ***
USE ../data/pbs!notesmenu SHARED IN 0
*** Store it ***
lcID = idgenerate() && Generate a unique ID
REPLACE NID WITH lcID
REPLACE NTITLE WITH M.UPLOADTITLE
REPLACE NURL WITH lcfilepath
<BODY TOPMARGIN="0" LEFTMARGIN="0" BGCOLOR="#D1E5F3">
<form action="iUpload.fwx" method="post" enctype="multipart/form-data">
<TD ALIGN="Left" VALIGN="TOP"><B>Title</B></TD>
<INPUT TYPE=text NAME="UPLOADTITLE" SIZE=80 MAXLENGTH=100 VALUE="<%=(M.UPLOADTITLE)%>">
<TD ALIGN="Left" VALIGN="TOP"><B>File to upload</B></TD>
<INPUT TYPE=file NAME="UPLOADFILE" SIZE=70 MAXLENGTH=100 VALUE="<%=(M.UPLOADFILE)%>">
<TD ALIGN="Left" VALIGN="TOP"><B>Choose</B></TD>
<INPUT TYPE="SUBMIT" NAME=btnchoice VALUE="Upload">
*** END OF SOURCE ***
Sent by FoxWeb Support on 09/04/2003 04:59:03 PM:
The upload.fwx script and the techniques employed by it have been utilized in many applications with no known issues. Please provide additional details on the nature of the problem.
Sent by Joe Goldsmith on 09/03/2003 08:45:34 AM:
Hello. I was using the upload.fwx example to upload files but realized that some files, such as .zip, was not uploading. IS there a way to upload any type of file?