How to retrieve a file uploaded to the server?

Mar 7, 2013 at 10:26 PM
Hi

How do I retrieve a file uploaded from a form using method="POST" enctype="multipart/form-data"?

Thanks,
Simon
Coordinator
Mar 8, 2013 at 12:48 AM
You should be able to access the file that you uploaded from your code. The default for where it's uploaded is \temp but that can be changed. The following info is returned with the upload (from the demo):

1 File(s) Uploaded!
The first file is c:\avfp6\temp\FLL2012 Certificate Generic (2).ppt, Size: 630784, Original Name: FLL2012 Certificate Generic (2).ppt

The second file is , Size: , Original Name:

The third file is , Size: , Original Name:

The 1st value you entered is:

The 2nd value you entered is:

The 3rd value you entered is:

File1 extension and stem are: .ppt and c:\avfp6\temp\FLL2012 Certificate Generic (2)

File1 elapsed time for upload: 0

File2 elapsed time for upload:
Mar 8, 2013 at 3:20 AM
Hi

I saw in the code that it went to the temp folder but I wondered how I would know the name of the file. I f I just look in the temp folder I could be grabbing files from different users and not the one I want.

Simon
Coordinator
Mar 8, 2013 at 11:25 AM
Edited Mar 8, 2013 at 11:40 AM
You can always have the user log in and pass that info (or any other text fields like in the example form) along with the upload. All of that info is associated with the upload. The code for getting the file name is in that sample app (from http://70.174.157.27:444/avfp6/upload2.avfp ):
* do the upload     
    lnFiles = oUpload.HttpUpload(oProp.AppStartPath+'temp')
%>                  
                  <tr>
                    <td width="149%">
                    <%= oUpload.lnfCount %> File(s) Uploaded!
                    <p>The first file is <%=oUpload.getfilename('FILE1')%>,
                    Size: <%=oUpload.getfilesize('FILE1')%>, Original Name:
                    <%=oUpload.getfileorig('FILE1')%></p>
                    <p>The second file is <%=oUpload.getfilename('FILE2')%>,
                    Size: <%=oUpload.getfilesize('FILE2')%>, Original Name:
                    <%=oUpload.getfileorig('FILE2')%></p>
                    <p>The third file is <%=oUpload.getfilename('FILE3')%> ,
                    Size: <%=oUpload.getfilesize('FILE3')%>, Original Name:
                    <%=oUpload.getfileorig('FILE3') %></p>
                    <p>The 1st value you entered is: <%=oUpload.getmform('test')%></p>
                    <p>The 2nd value you entered is: <%=oUpload.getmform('test2')%></p>
                    <p>The 3rd value you entered is: <%=oUpload.getmform('test3')%></p>
                    <p>File1 extension and stem are: <%=oUpload.getfileex('FILE1')+[ and ]+oUpload.getfilestem('FILE1')%></p>
                    <p>File1 elapsed time for upload:<%=oUpload.getelapsedtime('FILE1')%></p>
                    <p>File2 elapsed time for upload:<%=oUpload.getelapsedtime('FILE2')%>
Mar 9, 2013 at 2:30 AM
I think what led to a little confusion was the class name AVFPHTTPUpload. I did not realize until I analysed the source code that the upload had already taken place and that the AVFPHTTPUpload class was merely retrieving the data from the Request object. The class itself had nothing really to do with the uploading process. Once I understood that everything else made sense and it works just fine.

Thanks,
Simon
Mar 17, 2013 at 10:54 PM
when I run Upload1.avfp and Upload2.avfp always shows 0 file uploaded and the folder TEMP also empty only.
What could be the reason ? IIS setting or missing class in my AVFP ? please help.
Coordinator
Mar 18, 2013 at 2:56 PM
Edited Mar 18, 2013 at 3:31 PM
Assuming you chose a file to upload, the Temp folder has to be writable. Check permissions.