Frustration with File Uploads Form

Hi all,

I’ve just about had it up to my eyeballs with a file upload form application in scriptcase 8, and I’m looking for suggestions. Here’s what I’ve got:

I have a table, ss_files. It’s pretty straight forward, but here’s what the structure looks like:

There seems to be two methods for file upload in scriptcase –
[LIST=1]

  • Upload to Database using "Document (Database)" (Scriptcase seems to heavily prefer this method. I don't.)
  • Upload to Directory on Server using "Document (File Name)" (My preference, but Scriptcase won't create the directories as specified) [/LIST]

    I’ve tried this using both methods.

    With method #1 I can get the file to upload to the database in the binary_data field, but I cannot figure out how to write an application to retrieve the file from the database afterward. This really does not break my heart, because the last thing I want is a bunch of file uploads bloating a table in my database and causing long-term havoc. Still, it’s frustrating to see the file there in the field with the proper byte size and have no way to access it other than using a third party utility like phpMyAdmin. I need a way for employees to access these files.

    With method #2 I can get the file to upload to the /lib/tmp folder, but Scriptcase modifies the file name to be something like sc#######[Filename.ext]. It ignores my directive to create subfolders using the variables. It always puts the file in /_lib/tmp instead of moving the file to /vault/{customer_id}/{module_id}/{reference_id} as requested. It does not populate the “file_name” field in the database. It makes the entire table seem pointless for tracking what files have been uploaded and where they reside.

    Am I missing some key detail here? I’ve watched the video tutorial on this, which did not answer any questions for me. I’ve searched through the help documentation, which is similarly unhelpful. I’ve searched the forums but not found my exact problem, detailed above. I’ve tried it in a development environment and also deployed out to a QA environment with no major change. I was even hoping to look through the provided ScriptCase Ticketing system sample application for how they were managing file uploads, but it seems that when I upgraded to SC8, this ticketing sample app was broken and does not compile any longer.

    Any help would be appreciated!

    table_structure.jpg

  • at #2 scriptcase uploads the file into the default directory if you are not changing that. You can if you deploy in the advanced mode. there you can set the root upload directory. After that you can use the properties for subdirs etc.

    2 Likes

    Albert,

    As usual your advice led me down the path that I needed to go down to solve this problem.

    Here’s what I was missing:

    1. The fact that the file was appearing not only under /lib/tmp with the sc#####[filename.ext] but also in /_lib/file/doc as well. With the directory path specified as I had it, it actually appeared in /_lib/file/doc0/5/filename.ext . Once I found that I modified my directory path to say ./{customer_id}/{module_id}/{reference_id} so it would drop in /file/doc properly. I don’t mind it appearing there instead of /vault… I just minded that the files did not seem to be going anywhere other than the tmp folder and with a random prefix that I could not create links to.

    2. The fact that the permissions on /_lib/file/doc needed to allow apache to write to them. As it turns out the folder this all drops in is owned by another user on the server, and this was messing with apache’s ability to write the file into the folder. So I chown’ed /_lib/file/doc to be apache:[user] and that resolves apache’s ability to write to the folder.

    Now in my grid view of all the uploaded files, I have a link to the uploaded file, and it works! Thanks for your help!

    2 Likes

    Hello. I have a similar problem. I am uploading a csv file and everything works on development environment. When I move to production environment, The upload didn?t work. I made the changes Anomaly0617 made related to the _lib/tmp and _lib/files/doc directories. Now the upload works, but, when trying to populate a mysql table I get the following error: PDOStatement::execute(): LOAD DATA LOCAL INFILE forbidden. I have already modified the my.cnf file adding local-infile=1 for mysql and mysqld. As I said, on development environment it works, even using mysql console, it is related to some production environment configuration. Thanks in advance for any help.

    If you upload to a directory then be sure that you have sufficient rights. Depending on your hosting the owner of the directory could be ‘apache’ for instance causing trouble. If you store in the mysql database then the max. size of the file must be configured. I’ve never seen your error message however… There are loads of google results, but I couldn’t find the cause. It for sure is a configuration issue within your php/mysql environment.

    Just in case anyone else ends up here, I just discovered that if you put the subdirectory in the upload field settings as , say zipfiles it will work locally but not in production. You have to put /zipfiles as the subdirectory it saves to, and then it works in both. Took me 2 hours to work that one out. Also remember to deploy using the advanced settings as that is the only way to set the file directories. Mine were wrong. I am not sure, but I suspect you need to deploy all your apps using the advanced method, as I suspect it is held a session variable and will depend on which app you are using at the time. May be wrong, but no harm doing this to be safe. By the way, also just realized that those files held in the temp directory are deleted after a value set by accessing the backend at /_lib/prod/lib/php/nm_ini_manager2.php . In my case I want to unzip some files , this is a good place so the zip files is deleted after some time and they don’t build up.

    I am having the exact reverse issue… in my development environment (hosted with http://scriptcase.host) if I do a file upload it makes it to the TMP folder where I can see it… but it doesn’t ever save it to the DOC folder… if I publish to production… it works!

    Any ideas on how to fix it? I asked for support with the host but they directed me back here for support.
    Thanks!