Uploaded / attachment document on Form not saving to default Scriptcase path

Good evening,

I’ve got a form that captures information and emails it out which is working fine. I’ve added to that form, a new field in the database (of type ‘text’) for adding a document attachment. Scriptcase field type is “document (file name)” so that just the file name is stored in the database and the file saved in Scriptcase’s default document path. When I add the document (via browse or drag and drop) it all appears to work fine, but when I click on the final button to add the record to the database, I get:

Fatal error: Uncaught exception ‘Swift_IoException’ with message ‘Unable to open file for reading [/home/user/NetMake/v81/wwwroot/scriptcase/file/doc/test.txt]’

I think I’ve figured out the reason it can’t read that file is because it’s not there!?? In main Settings, my document path is the usual /home/user/NetMake/v81/wwwroot/scriptcase/file/doc but nothing is being saved there. If I manually save the test.txt to the /home/user/NetMake/v81/wwwroot/scriptcase/file/doc path and run my form again (attaching the same named file), it works fine - email goes out with the correct attachment. But if I try to add a new file (that doesn’t already exist in the doc directory, I get the same error as listed above.

Anyone have any idea what I could have done wrong? I’ve done this numerous times in the past and don’t remember ever having to do anything other than select the field type in Scriptcase to be “document (file name)” and then any uploaded document is automatically saved in that location, and the file name is saved in the database field.

I’m running the latest Scriptcase version on Ubuntu 16.04. I checked permissions and even set them to 777 but still the same issues. Documents added to a form’s “document (file name)” field don’t get uploaded at all…and no errors thrown related to them not being able to be saved to the /home/user/NetMake/v81/wwwroot/scriptcase/file/doc/ path

Thanks very much in advance for any directives / suggestions.

EDIT: For kicks, did a search for test.txt and there are a bunch of oddly named files in /home/user/NetMake/v81/wwwroot/scriptcase/tmp that seem to be my test file, but nothing in the /home/user/NetMake/v81/wwwroot/scriptcase/file/doc/ directory still… confused.

Please check if you can even upload to that path in other ways.
First of all files upload with scriptcase FIRST go to a temp directory!! then when you are done on your form they are moved to the destination dir.
So you have to check the rights on your tmp dir as well…

Thanks for the tip @rr1! During my investigation last night, I ran chmod -R 777 on the scriptcase directory so everything ‘should’ have full rights but will go and look at that specific directory and confirm its rights. As I mentioned in my edit, I do see several temp files in the tmp directory matching the file I’m trying to upload, but based on your feedback, they’re unable to be moved to the doc directory… I will take a look at that project ASAP.

Thanks again!

Check your php error log it may be mentioned in there what goes wrong

Clearly I must be doing something wrong here because I still can’t get this to work. I moved my development back over to a Windows machine (because that’s what used to work fine for me) instead of Ubuntu but I’m plagued with the same problem. If I add a field for a document to be saved with a form submission (file name, not database), the file is never saved to the default directory. However if I change that field to be an image (file name), it’s saved to the default image directory just fine. I’ve checked permissions on both folders on my windows machine here (D:\Program Files\NetMake\v81\wwwroot\scriptcase\file\doc and img) and they are both set to Write for everyone.

When I attach a document, it DOES appear in the D:\Program Files\NetMake\v81\wwwroot\scriptcase mp directory, but is never moved over to the D:\Program Files\NetMake\v81\wwwroot\scriptcase\file\doc directory…

The field type in my MySql database for this field is Text and to allow nulls.

What could I be missing here? When I look at the Options/Settings/System Folders for the default file locations, the only odd thing I see is that the doc directory has the full path (D:/Program Files/NetMake/v81/wwwroot/scriptcase/file/doc) where as the img directory just has an abbreviated one (/scriptcase/file/img). For kicks I changed the doc one to a similar format as the img, but still…nothing is being written to the doc directory.

Any help would be much appreciated.

Thanks in advance,

Mark.

The file will be moved when you close the window. Actually it basially gets moved when the commit in the window is done.
Just make a little file uploader program with nothing else then an upload field. Deploy it and test it out. You’ll see the uplaoded file appear with an altered name (with sc_… something in it).
Only when you close application will your file be moved from the tmp to the dir where it needs.
I assume you do have deployed with the advanced deployment and that you have set the paths and dirs and so on that belong to the advanced deployment settings.

Hi rr,

As always, thank you for your feedback, it’s very much appreciated. I tried your suggestion and created a new form with just the upload field for the mysql database and it works… so thank you for that. I was so wrapped up in trying to figure out why it wasn’t working, I didn’t step back to test something simple. Still, I’ve deleted all the events from my original form, and it’s still not uploading the doc. I will continue to troubleshoot for a while because I’ve spent so much time in making the form look good (with different spacing / blocks, that I don’t want to start all over again. There are about 45 fields and it will take a long time - but if that’s what I end up having to do, so be it. At least I have a way to get to a working final product again, thanks to you.

Thanks again so much rr!

Were you ever able to figure out what the problem was? My hosting company just moved me to a new server and since then I have had a similar problem. The file uploads to the temporary directory but never gets copied to the final folder. No errors in php file – all folder permissions set to 755. The only difference that I have found was php version 5.4.26 (original version used to create the app) and 5.4.45 current php version running the app. In addition, I have a create a link to the file and save that in the database as well. The links to all of the files that were created prior to the server change still work and bring up the correct “pdf” file. Any assistance would be appreciated.

Modified the php.ini to copy the ini to all sub-directories and got two new errors that seems to be related.

PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in /path to file/_lib/lib/php/upload.class.php on line 232

PHP Warning: Cannot modify header information - headers already sent by (output started at /path to file/_lib/lib/php/upload.class.php:232) in /path to file/_lib/lib/php/upload.class.php on line 382

The upload.class.php file that is being used:

Header info
/*

Simple fix for this environment – Linux, Apache, MySQL – on a shared server

– just needed to add the text below to the php.ini file

[Date]
date.timezone = America/Chicago

Also, important to note that this server configuration has multiple sub-domains and each has a slightly different php.ini file. Therefore, this specific php.ini had to reside in all folders related to this app. Added the following to an htaccess file:

suPHP_ConfigPath …path to files…