No announcement yet.

File Uploads... Very Confused...

  • Filter
  • Time
  • Show
Clear All
new posts

  • File Uploads... Very Confused...

    Form.jpgField Properties.jpgHi all,

    I've been coding in PHP since 2004, and perhaps that's my problem. Perhaps I'm over-thinking this, but I'm very confused about file uploads from a form in ScriptCase...

    Here's what I'm trying to accomplish:

    I want users to be able to upload a file, whether it's an image or a document or measurements on the playboy model of the year, from a form. When they upload it, I want the file to be available like this:

    User uploads "measurements.txt"

    File appears as available here:

    The subdirectories there refer to the customer_id (107) and the ticket_id (20141002.172034) that the file belongs to.

    At the same time an entry is created in a table called customers_files with the following data:
    file_id int(7) No None AUTO_INCREMENT
    customer_id int(7) No 0
    file_name text latin1_swedish_ci Yes NULL
    ip_addr varchar(15) latin1_swedish_ci No
    created timestamp No CURRENT_TIMESTAMP
    To me all of the above seems reasonable, but when I've tried to create the upload field.... it does not work. The file "uploads" but no entries are saved in the table, and I cannot find the file anywhere. In addition, ScriptCase seems to want to save all the files INTO the database as binary BLOB data. Over time this will just bloat the database and make it unusable.

    I'm going to try to attach screenshots of my attempt to make this work to this ticket. At the moment it's feeling like I have to code my own file uploader, which would suck considering we purchased Scriptcase precisely to avoid coding our own custom stuff all the time.

    Any help accomplishing the above without a ton of hassle would be greatly appreciated.
    Last edited by anomaly0617; 10-02-2014, 06:38 PM.

  • #2
    The file upload uploads the file indeed. If you want to save it as a file you need to save it as document file name then it gets stored as file on a path somewhere (you set where).


    • #3
      Originally posted by rr View Post
      The file upload uploads the file indeed. If you want to save it as a file you need to save it as document file name then it gets stored as file on a path somewhere (you set where).
      Hi RR,

      Thanks for the reply. Can you clarify? Based on your response, here are the steps I have taken:

      1. I verified and when I edit my Form, Under Form Settings -> Edit Fields -> field "Upload" -> (Edit icon) -> General Settings -> Data Type it is for certain set to Document (File Name)
      2. Subfolder is set to the variable {customer_id}
      3. Then I Generate and Run the Form.
      4. I select a file, Test.txt, from my laptop hard drive
      5. I upload it, and it indicates that the upload was successful.
      6. I then SSH into my development server and using Midnight Commander, I search the entire server hard drive starting at / for Test.txt, both case-sensitive and not case-sensitive. It does not find the file. (Update see below)

      Can you clarify where it is uploading the file?

      I found the file by erasing all files in /opt/NetMake/v8/wwwroot/scriptcase/tmp and then uploading the file again. It gave it the name sc_9c499e2d_Test.txt. So the question now is, how do I get this file to appear as, for example, /opt/NetMake/v8/wwwroot/scriptcase/app/{AppName}/file/doc/{customer_id}/{ticket_id}/Test.txt? If I have to code this as an event, I'm fine with that, but a little instruction on how to go about this would be appreciated.

      Note: I've already set the absolute path setting under Application Settings for doc and img to /opt/NetMake/v8/wwwroot/scriptcase/app/{AppName}/file/doc. Even when I remove the value from the subfolder field, no file appears here. I've also made sure (for the sake of testing) that every folder from /opt all the way through ./doc has 777 permissions on it, to eliminate permissions issues.

      Last edited by anomaly0617; 10-06-2014, 05:17 PM. Reason: Additional Info


      • #4
        This will work:

        In Application > Document Path > \_lib\file\doc

        In the Document upload field under subfolder property> /{field1}/{Field2}/{field3}

        This will save a document to the root in of your project folder, make sure create subfolder is checked.

        So you will get something like this:

        In root of project folder: "/Project_Name/_lib/file/doc/field1/field2/field3/Test.txt"
        Last edited by mikelaw; 10-07-2014, 05:37 AM.


        • #5
          In your deployment choose advanced deployment to have your uploads appear in another folder. I made that mistake in an older sc version. If you use the standard generate then it indeed goes as mikelaw says. In your deployment you can choose another path.