close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple file uploads with multiple inserts into - confused need help DB

Thread began 7/01/2011 6:21 pm by YellowCircleWeb | Last modified 4/19/2021 9:51 am by Ray Borduin | 7174 views | 21 replies |

YellowCircleWeb

Multiple file uploads with multiple inserts into - confused need help DB

I'm trying to create a form that allows a user to upload up to 5 separate photos and then to have these photos inserted into a database.

I've made sure my file upload fields are all uniquely named and created 5 image upload server behavior instances, one for each of the file fields. I'm confused as to how to go about performing the multiple insert into the database after the upload.

Am I able to use a repeat selection on my file fields and then use the multiple insert behavior from DataAssist?

I'm confused about the field bindings too. I have 5 uniquely named file fields, but the Multiple Insert record wizard asks me to choose a single field for each of the database columns meaning there will only ever be one image uploaded 5 times.

I've considered adding 5 separate single record insert behaviors but then how would I know when to do the re-direct as each behavior would have it's own redirect instruction.

Any help is greatly appreciated.

I've attached a copy of my page

Attached Files
freelancer-merch-image-upload.zip
Sign in to reply to this post

Jason ByrnesWebAssist

no, you cant use the multiple insert behavior with file uploads.


this is going to take some hand coding to pull off.


you will need to store the server file name of the uploaded files into a session variable array.

then, set up a single insert record behavior that has an array loop around it.

by naming a session with "[]" it will create an array, for example:
$_SESSION['uploadedFiles'][]

use the following code after the upload file behaviors to store the uploaded files into the session array:

php:
<?php

if($WA_DFP_UploadStatus["WA_UploadResult1"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult2"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult2"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult3"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult3"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult4"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult4"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult5"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult5"]["serverFileName"]; 
?>




then add the insert record behavior to the page, for the column that will store the file name, paste the following code into the value box:

php:
<?php echo $_SESSION['uploadedFiles'][i]; ?>




now add an array loop around the insert behavior:

php:
<?php for($i 0$i sizeof($_SESSION['uploadedFiles']); $i++) { ?>

<insert record code here>
<?php ?>
<?php 
if(sizeof($_SESSION['uploadedFiles']) > 0) {
  unset(
sizeof($_SESSION['uploadedFiles']));
  
header("Location: successpage.php");
}




the second if will unset the session and redirect to the success page.

Sign in to reply to this post

YellowCircleWeb

Thank you very much for the info Jason. Great support, as always.

Just out of interest are there any plans to include this functionality in future versions of Digital File Pro/Data Assist?

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

I'm not sure if there are plans to include this or not.

as always, if there are features you would like to see implemented, you can post your request to the wishlist forum to have them taken into consideration.

Sign in to reply to this post

sublucentBeta Tester

Multiple uploads, multiple inserts, multiple problems

Hello,
I'm trying to use this page to insert some item details into one table, two details into two different relational tables, image info from three images into another table and upload the images. I think the different WebAssist products may be stepping on each others toes. I can get everything to work independently except for the insert record for the images.
After I added the Manage Relational Table I ran into this problem:
Fatal error: Cannot redeclare WA_AB_getLoopedFieldName()
If I comment out line 4 I get numerous errors.
If I comment out line 2 (and lines 332-336 see below) it will work except for the 2nd Manage Relational Table, and the insert record for the images will insert one record and a blank line for the file name in the table.
Also, I get Fatal error: Can't use function return value in write context in on line 334.
What a mess. I hope you can help me sort this out.
I've attached the problem file.
Thank you so much for your help.

Attached Files
item_Insert.zip
Sign in to reply to this post

Jason ByrnesWebAssist

line 334:
unset(sizeof($_SESSION['uploadedFiles']));


should be:
unset($_SESSION['uploadedFiles']);


the other problem on the page is that you have added the array loop around the insert and the MT behaviors, the for each loop should only be added around the insert record behavior for the images.


Go back to the beginning and get the page working with every thing except the image upload and the insert for the image names, once you have that in place, add the image upload and the insert for the image names.

The reality is that the code I gave in my previous reply to this thread is not supported code, you will need to have an understanding of what that code is doing to be successful using it.

Sign in to reply to this post

sublucentBeta Tester

Insert Record and Manage Relational Table conflict

I understand the code that you provided in this thread isn't supported. (Thanks for the help with it, hopefully I will get to a point to try out your suggestion.) I was mostly concerned with whether any of the WebAssist extensions were causing problems or if it was that code.

So far in the latest rebuilding of the form I have found that everything was working until I added Manage Relational Table from DataAssist. It inserts: <?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?> and Insert Record already has: <?php require_once("../webassist/database_management/wa_appbuilder_php.php"); ?>.
I get this error: Fatal error: Cannot redeclare WA_AB_getLoopedFieldName() (previously declared in F:\wamp\www\IDOM\WA_DataAssist\WA_AppBuilder_PHP.php:12) in F:\wamp\www\IDOM\webassist\database_management\wa_appbuilder_php.php on line 20

I get errors if I remove the one for the Insert Record and if I remove the other the relational table isn't inserted, even if I add <?php require_once("../WA_DataAssist/library.php"); ?>.

Any ideas on how I can work around this?
Thank you!

Attached Files
item_Insert2.zip
Sign in to reply to this post

Jason ByrnesWebAssist

I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
supporthistory.php

If anyone else is experiencing this same issue, please append to this thread.

Sign in to reply to this post

Morgan

Originally Said By: Jason Byrnes
  no, you cant use the multiple insert behavior with file uploads.


this is going to take some hand coding to pull off.


you will need to store the server file name of the uploaded files into a session variable array.

then, set up a single insert record behavior that has an array loop around it.

by naming a session with "[]" it will create an array, for example:
$_SESSION['uploadedFiles'][]

use the following code after the upload file behaviors to store the uploaded files into the session array:
php:
<?php

if($WA_DFP_UploadStatus["WA_UploadResult1"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult2"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult2"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult3"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult3"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult4"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult4"]["serverFileName"]; 
if(
$WA_DFP_UploadStatus["WA_UploadResult5"]["statusCode"] == "1"$_SESSION['uploadedFiles'][] = $WA_DFP_UploadStatus["WA_UploadResult5"]["serverFileName"]; 
?>



then add the insert record behavior to the page, for the column that will store the file name, paste the following code into the value box:
php:
<?php echo $_SESSION['uploadedFiles'][i]; ?>



now add an array loop around the insert behavior:
php:
<?php for($i 0$i sizeof($_SESSION['uploadedFiles']); $i++) { ?>

<insert record code here>
<?php ?>
<?php 
if(sizeof($_SESSION['uploadedFiles']) > 0) {
  unset(
$_SESSION['uploadedFiles']);
  
header("Location: successpage.php");
}



the second if will unset the session and redirect to the success page.  



Is this code still useable?
Cos its what i need to get my multiupload to work with out a loads of empty posts in my db.

Ah well i try it out! :)
You guys at WA should really build that multiupload in to DataBridge, old Interakts extention had a awesome one, ctrl + click any file/files, bam right in the kisser, i mean in to the database, easy as making pie. :)

/Morgan

Sign in to reply to this post

Jason ByrnesWebAssist

Yes this code is how you can create a multiple file upload system.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...