Alpha DevCon 2018
Results 1 to 12 of 12

Thread: Uploading file

  1. #1
    VAR Dan Blank's Avatar
    Real Name
    Dan Blank
    Join Date
    Apr 2000
    Location
    Fort Worth, TX
    Posts
    995

    Default Uploading file

    Is it possible to allow a customer to upload a file through WAS? Similar like we upload a file or image for this message board.

    I want to put a browse button on a form and let the customer browse through their computer to find the file, then push submit to upload the file to the web server.

    Thanks,
    Dan

    Dan Blank builds Databases
    Skype: danblank

  2. #2
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,578

    Default Re: Uploading file

    Dan,

    Here is an example I put together from the examples, the help and help from Steve Workings:

    The following code goes in the <head></head> section. This sets up where the upload will be saved and also appends a session variable (in this case car_id) as a prefix so I can view the uploads for a particular record. It also creates a message for feedback to the user.

    Code:
     
    if eval_valid("cmd")
        file.from_blob(ServerSetting.Document_Root+"\\calmax\\uploads\\"+session.car_id+"."+FileToUpload.filename, FileToUpload.data)
        vMsg = "<a href=\"/" + FileToUpload.filename + "\" target=\"_blank\">" + FileToUpload.filename + "</a> was uploaded."
    end if
    The following code goes in the body. It creates the form and the buttons.

    Code:
     
     <p><form action=" <%a5 ? request.script_name %> " method ="post" enctype="multipart/form-data">
     <input type="file" name="FileToUpload">&nbsp;<input type="submit" name="cmd" value="Upload File"></form></p>
    A picture of how this looks is attached.

  3. #3
    VAR Dan Blank's Avatar
    Real Name
    Dan Blank
    Join Date
    Apr 2000
    Location
    Fort Worth, TX
    Posts
    995

    Default Re: Uploading file

    Excellent!!!!!
    Thank You so much!
    This will be a big help!

    Thanks Again,
    Dan

    Dan Blank builds Databases
    Skype: danblank

  4. #4
    Moderator
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,550

    Default Re: Uploading file

    The basic code and approach is easy to extend. See attached pic.
    -Steve


  5. #5
    Member StephenP's Avatar
    Real Name
    Stephen Pilon
    Join Date
    Apr 2000
    Location
    Front Royal, Virginia
    Posts
    490

    Default Re: Uploading file

    I've built an import function based on the code in this post, but when I run it on my localhost to test it, the server freezes on me. Here is the code I put in my header:

    Code:
    <%a5
    dim vMsg as c
    vMsg = ""
    if eval_valid("cmd")
        dim filename as c
        dim excel_str as c
        dim excel_dbf as c
        dim excel_tbl as c
        dim excel_tmp as c
        
        excel_tmp = file.filename_parse(FileToUpload.filename,"n")
        excel_tbl = excel_tmp+"$"
        excel_dbf = "[PathAlias.ADB_Path]\\"+excel_tmp+"_.dbf"
        filename = "[PathAlias.ADB_Path]\uploads\\"+FileToUpload.filename
        file.from_blob(filename, FileToUpload.data)
        excel_str = "Provider=MSDASQL;Driver={Microsoft Excel Driver (*.xls)};DBQ="+filename
        A5_ADOImportTable(excel_str, excel_tbl, excel_dbf, "", "", "", .t., .f., .t., .t., .t., "", .F.)
        vMsg=FileToUpload.filename + " was uploaded."
    end if
    %>
    The funny thing is that the excel file gets copied, and the tables are created, but the server never completes the task, and I'm not sure where it is hanging up.

    Any ideas? I've tried the same code in the desktop app, and it works. Is A5_ADOImportTable() valid on the web (as I said, it seems to create the tables, but it never refreshes the page to show the process as complete).

    Stephen
    Stephen Pilon
    Associate Librarian
    Christendom College

  6. #6
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,656

    Default Re: Uploading file

    Currently A5_ADOImportTable() does not report errors in a server-safe way. This means that if the server is hanging, there must be some problem that is causing your import to fail.

    We will attempt to update A5_ADOImportTable() in a future patch so that it is server-safe and reports errors properly.

    -Lenny

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  7. #7
    Member StephenP's Avatar
    Real Name
    Stephen Pilon
    Join Date
    Apr 2000
    Location
    Front Royal, Virginia
    Posts
    490

    Default Re: Uploading file

    Lenny,

    Thanks for your response. Does this mean that if I can find my error, then the script should work? I guess even if it does, it would be better to wait for the patch. I suppose I'll need to find another way to import the records.

    Thanks again,

    Stephen
    Stephen Pilon
    Associate Librarian
    Christendom College

  8. #8
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,656

    Default Re: Uploading file

    Yes, if you can find and fix your error, your import should work.

    Also, I have to apologize because I had not noticed that you posted this in the version 7 area. We will be fixing this in version 8 with a patch, but version 7 will not be patched.

    -Lenny

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

  9. #9
    Member
    Real Name
    Julie Alley
    Join Date
    Apr 2008
    Location
    Seattle, WA
    Posts
    89

    Default Re: Uploading file

    Hi all,

    I am trying to use Pat's sample, but the first code that is placed between <head></head> section is showing up when I view the page for testing, after posting as just text.

    Do I have this in the wrong place?

    Thanks

    julie

  10. #10
    Member
    Real Name
    Julie Alley
    Join Date
    Apr 2008
    Location
    Seattle, WA
    Posts
    89

    Default Re: Uploading file

    Hi Steve,

    I am curious how you expanded your code to include the category - I am working on implementing a similar solution.

    Thanks,

    Julie

  11. #11
    Member
    Real Name
    Jason Christiansen
    Join Date
    Mar 2009
    Location
    Brisbane Australia
    Posts
    167

    Default Re: Uploading file

    Hi Steve

    I am having an issue with my file upload page, was hoping you may have an idea where I'm going wrong. The following code is inserted into my file upload page:


    <html>
    <%a5
    dim msg as c = ""
    if eval_valid("cmd")
    dim fn as c
    fn = "[PathAlias.Images_Path]" + "\\"+ FiletoUpload.filename


    file.from_blob(fn, FileToUpload.data)

    msg = "<a href=\"/" + FileToUpload.filename + "\" target=\"_blank\">" + FileToUpload.filename + "</a> was uploaded<br /><br />"

    end if

    %>
    <head>
    <title>File Upload example</title>
    </head>
    <body bgcolor="#ffffff">
    <%a5 ? msg %>
    <form action=" <%a5 ? request.script_name %> " method="post" enctype="multipart/form-data">
    <input type="file" name="FileToUpload">&nbsp;<br >
    <input type="submit" name="cmd" value="Upload File">
    </form>
    </body>
    </html>

    I had this working perfectly on Friday, but over the weekend I shut the PC down (and App Server simultaneously), and then this morning when I fired the PC up and opened Alpha, I now get the following message as per the attachment.

    Any ideas where I am going wrong? I checked the page security and it doesnt appear to be the cause

    Many thanks

    Jason

  12. #12
    Member
    Real Name
    Jason Christiansen
    Join Date
    Mar 2009
    Location
    Brisbane Australia
    Posts
    167

    Default Re: Uploading file

    Steve

    If you do read this, I managed to sort the problem

    Jason

Similar Threads

  1. uploading files
    By johnm in forum Web Application Server v7
    Replies: 2
    Last Post: 08-29-2006, 04:36 AM
  2. Uploading a File to a Web Site
    By KeithW in forum Web Application Server v7
    Replies: 0
    Last Post: 08-08-2006, 12:07 AM
  3. Uploading Photos.
    By robert swanson in forum Web Application Server v6
    Replies: 4
    Last Post: 09-27-2005, 11:34 PM
  4. Format changes on uploading
    By Robert Rough in forum Web Application Server v6
    Replies: 8
    Last Post: 06-23-2005, 11:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •