HTML5 File Upload Support Product Page
Unique filename not being inserted into database table
Asked 02 Dec 2016 14:22:53
1
has this question
02 Dec 2016 14:22:53 David Woolley posted:
I'm uploading images to the server where the filename is recorded in a database table: imagesThe original image uploaded uses the template {name}{_n}{ext} in case an image with the same name is uploaded again. Then a large and small image is created with the same filename in 2 separate folders /large/ and /small/
This is all working well except for one thing:
The filename reference in the images table is not being created with the _1 suffix like the actual uploaded image (e.g. myimage_1.jpg), so the insert record complains. I have set the 'imagename' field with a UNIQUE index.
The Server Action file is set up like so:
DB Connection
File Upload template: {name}{_n}{ext}
Load image
Resize image
Save image (large) template: {name}{_n}{ext}
Load image
Resize image
Save image (small) template: {name}{_n}{ext}
DB Insert
Where imagename = {{imageUploaded.name}} from File Upload step
Why does the Insert step not use the name generated from the File Upload step? (e.g. myimage_1.jpg)
Replies
Replied 02 Dec 2016 14:39:05
02 Dec 2016 14:39:05 Teodor Kuduschiev replied:
Hello David,
I cannot recreate such an issue, just tested this locally. The {{imageUploaded.name}} correctly returns the uploaded AND renamed image name. Make sure you have everything setup correctly.
I cannot recreate such an issue, just tested this locally. The {{imageUploaded.name}} correctly returns the uploaded AND renamed image name. Make sure you have everything setup correctly.
Replied 05 Dec 2016 11:43:58
05 Dec 2016 11:43:58 David Woolley replied:
Hi Teodor - I've tested this a few more times with various filenames with and without spaces, but still not adding the suffix '_1' to the filename reference in the images table.
File Upload settings:
Name: imageUploaded
Upload fields: {{$_POST.imagename}}
Path: /catalogue
Template: {name}{_n}{ext}
Replace spaces: Y
Diacritics/accents: Y
Strip non-ASCII: Y
Overwrite: N
Create Path: N
Throw errors: N
Output: N
I could send you some screenshots - unfortunately not live yet.
File Upload settings:
Name: imageUploaded
Upload fields: {{$_POST.imagename}}
Path: /catalogue
Template: {name}{_n}{ext}
Replace spaces: Y
Diacritics/accents: Y
Strip non-ASCII: Y
Overwrite: N
Create Path: N
Throw errors: N
Output: N
I could send you some screenshots - unfortunately not live yet.
Replied 05 Dec 2016 11:54:07
05 Dec 2016 11:54:07 Teodor Kuduschiev replied:
Please send me screenshots of how are the insert and upload steps configured? As well as a screenshot of your server connect tree, to see the steps there.
Replied 06 Dec 2016 12:15:47
06 Dec 2016 12:15:47 David Woolley replied:
Hi Teodor
I solved the problem at last
The template for the File Upload step {name}{_n}{ext} does NOT work.
It created the unique filename for the file system, but does not create the same unique filename reference for the DB Insert or DB Update step.
However this does work for me: {name}{guid}{ext}
Same unique filename in file system & database table.
It would be nicer to be able to use {_n} of course, as I'd rather have a more intelligible filename!
Cheers
Dave
I solved the problem at last
The template for the File Upload step {name}{_n}{ext} does NOT work.
It created the unique filename for the file system, but does not create the same unique filename reference for the DB Insert or DB Update step.
However this does work for me: {name}{guid}{ext}
Same unique filename in file system & database table.
It would be nicer to be able to use {_n} of course, as I'd rather have a more intelligible filename!
Cheers
Dave
Replied 06 Dec 2016 12:32:38
06 Dec 2016 12:32:38 Teodor Kuduschiev replied:
That is strange as i tested this with {_n} and it appears to be working. But in your case it is a bit more complicated as it is is some condition which is kind of strangely setup - not quite sure what are you trying to achieve with it.
BTW the extension should automatically create unique filename if the overwrite option is off.
BTW the extension should automatically create unique filename if the overwrite option is off.
Replied 06 Dec 2016 13:41:12
06 Dec 2016 13:41:12 David Woolley replied:
I removed the condition step from the action file as I did not need to test if the file upload occurred for the Insert record step. This condition is only necessary for the Update record step, in case other fields in the table are updated without uploading a file.
I tested the {_n} with just a File Upload & Insert - also does not insert with the suffix.
Overwrite is OFF for all cases.
Maybe it's a DW CS6 problem ...?
Cheers
Dave
I tested the {_n} with just a File Upload & Insert - also does not insert with the suffix.
Overwrite is OFF for all cases.
Maybe it's a DW CS6 problem ...?
Cheers
Dave
Replied 06 Dec 2016 19:31:44
06 Dec 2016 19:31:44 Teodor Kuduschiev replied:
I don't believe so. There is something in your config that is probably wrong, but we need the action file and a link to your page.
Replied 07 Dec 2016 08:52:01
07 Dec 2016 08:52:01 David Woolley replied:
I've finally subscribed to DW CC 2017 so I will test with this as well, once I've got my head around the software.
Quite a big step upgrading from CS6 to CC 2017!
Cheers
Dave
Quite a big step upgrading from CS6 to CC 2017!
Cheers
Dave
Replied 07 Dec 2016 10:36:43
07 Dec 2016 10:36:43 Teodor Kuduschiev replied:
This is not really DW related. Please send me your action file so i can check it.