Getting trouble with uploading binary file using webspeed.

gnome

Member
Hi,
I am giving my webpage the capability of uploading both text & binary files however. My code only works with text files only in which I'm not really sure! That is because, i can upload files of .p, .i , .txt extensions but when I changed the .txt into .ini, It suprisingly didn't worked. :confused:
Environment:
OpenEdge 10.1B
Windows Server 2003
Apache 2.2

Heres what I did..
1. Set my Agent's file upload directory: C:\OpenEdge\WRK10.1B\root\webservicerequest\TEMP_UPLOAD
2. Set Binary upload Max Size : -1
3. Restarted the Agent.
Then run the code I found:

Code:
Code:
<HTML>
<BODY>
    <script language="SpeedScript">
        DEFINE VAR mFile AS MEMPTR NO-UNDO.
        DEFINE VAR cfile AS CHAR NO-UNDO.
 
       IF get-value('upload') <> '' THEN do:
        ASSIGN mFile = get-binary-data("browse").
        IF mFile <> ? THEN DO:
           {&out} 'Uploaded to: ' + get-config("fileUploadDirectory":U).
 
            ASSIGN cfile = get-value("browse").
            COPY-LOB FROM mFile TO FILE cFile NO-CONVERT.
        END.
        else
            {&out} 'Invalid file uploaded: ' + get-value('browse').
    END.
    </script>
    <FORM ENCTYPE="multipart/form-data"  ACTION="fileupload.r" METHOD="POST">
    <input type=file name="browse">
    <INPUT type="submit" value='upload' name="upload">
    </FORM>
</BODY>
</HTML>

This is probably about extensions. If it is, how can I manage to let webspeed upload files such as .jpeg or .bmp?


Thanks in Advance
 

gnome

Member
Re: RESOLVED! Getting trouble with uploading binary file using webspeed.

Great!

Surprisingly, When I tried to changed the lines:
Code:
ASSIGN cfile = get-value("browse").
            COPY-LOB FROM mFile TO FILE cFile NO-CONVERT.

to
Code:
ASSIGN  cfile = get-value('browse')
                    cfile_dest = get-config("fileUploadDirectory":U) + '\' + entry(num-entries(cfile),cfile,'\').
            {&out} 'Uploaded as: ' + cfile_dest.
            COPY-LOB FROM mFile TO FILE cfile_dest NO-CONVERT.

The upload finally worked!

('confused') ?? but when I removed the get-config("fileUploadDirectory":U) in the line :
Code:
ASSIGN cfile = get-value('browse')
cfile_dest = get-config("fileUploadDirectory":U) + '\' + entry(num-entries(cfile),cfile,'\').

Thinking that I have set the Transaction Server's File Upload Directory. The upload didn't "again" worked.

Is this a bug or I missed something.. This is just something I want to share that can be usefull in the future.


More power to Progress Users.
 

Cecil

19+ years progress programming and still learning.
Double check your apache configuration "form file uploads size" limits. I tested the code you submitted and it worked for me. The only thing I can think of is the binary files are generally bigger that a simple .txt file.
 

Cecil

19+ years progress programming and still learning.
Hi I am not sure where you are up to with your problem but I have done some of my own testing and I found that only ascii (text) files are stored in the "File Upload Directory".

I have not found out where binary files are being stored (yet) but I am guessing that they are being stored in memory and then flushed away once the WebSpeed session has been ended (i.e. content been sent back to the browser.).

So the up shot is that you must always use the get-binary-data function for all file types and don't bother with looking at the temporary directory.
 
Top