I stopped Scott Harwell without giving the right explanation why I stopped. I ignored it because it MAY be done, and I do it consistently. My code is as follows:
html tag:
<form id="inputForm1" method="POST" enctype="multipart/form-data" ACTION=""> <div id="file-attachment"> <div style="float:left;">file:</div> <div id="file-sub" style="float:left;"> <input type="file" id="WebAccessFile" name="WebAccessFile" size="45" value=""> </div> </div> </form>
the key is enctype="multipart/form-data"
My jQuery ajax statement looks like this:
$.ajaxFileUpload({url:'/LonApps/FoxWeb.exe/EWI/ewiprocedures?Proc=addrelease', secureuri: false, fileElementId:'WebAccessFile', dataType: 'text' });
I use Visual FoxPro as the coding language for this function, so I will post my VFP code, but you can simply adapt this code to which you have ever used the coding language:
loAttachment = Request.FormFieldObject("WebAccessFile") lcReleaseMessage = loAttachment.FileName lcSaveFile = "" IF loAttachment.ContentLength > 0 lcFileName = loAttachment.FileName lcFileContent = loAttachment.Value() lcSaveFile = "D:\Website\Publish\Depts\EWI\docs\" + lcFileName SET SAFETY OFF STRTOFILE(lcFileContent, lcSaveFile) SET SAFETY ON lcHTTPSaveFile = "/Publish/Depts/EWI/docs/" + lcFileName ENDIF
This takes an input value as loAttachment (lo stands for local object). Then, among other things, it is found that the length of the contents of the attachment is greater than 0, if this is the case, it saves the attachment in the local web directory for later access.
sadmicrowave
source share