close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple Record Insert with images

Thread began 3/01/2010 2:24 pm by troyd | Last modified 3/07/2010 5:43 pm by anonymous | 1244 views | 11 replies |

troyd

Multiple Record Insert with images

Is it possible to have a multiple record insert form that includes a file upload field?
I have a simple form that has just a couple of text fields and one file field that creates a large and thumbnail version of an image.

I've gone through the steps of creating the repeat selection and multiple insert and it works for all parts accept the image. Do I need to create a file upload behavior equal to the number of repeated form sections? If so, how would I bind them since a unique id is given during the repeat?

Thanks,
TroyD

Sign in to reply to this post

Eric Mittman

You will not be able to use the Digital File Pro upload with the repeated elements. You instead must have an upload for each file you want to upload. The names of the file fields will be whatever you have named them in the form with an _0 at the end for the first one. So if you have five file fields in a repeat selection area and the filed is named file1 the name of the fields you would need to reference in the DFP server behavior are:

file1_0
file1_1
file1_2
file1_3
file1_4

This should allow you to have your multiple uploads along with the multi insert, let us know if you have any further questions.

Sign in to reply to this post

troyd

Eric,

Thanks. That worked to get images uploaded. However it's inserting image #1 in all three records.

I have 3 record inserts. The file field is named image. So I have 3 WA Upload server behaviors. One for each image_0, image_1, image_2.

But in the Multiple Insert server behavior, how do I bind it? The other fields are recognized as repeat fields. I can only bind to one file field.

php:
<?php

mysql_select_db
($database_dbCMS$dbCMS);
$query_rsGallery "SELECT * FROM tblGallery ORDER BY id ASC";
setQueryBuilderSource($query_rsGallery,$WADbSearch1,false);
$rsGallery mysql_query($query_rsGallery$dbCMS) or die(mysql_error());
$row_rsGallery mysql_fetch_assoc($rsGallery);
$totalRows_rsGallery mysql_num_rows($rsGallery);
?>
<?php
$queryString_rsGallery 
"";
if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_rsGallery") == false && 
        
stristr($param"totalRows_rsGallery") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_rsGallery "&" htmlentities(implode("&"$newParams));
  }
}
$queryString_rsGallery sprintf("&totalRows_rsGallery=%d%s"$totalRows_rsGallery$queryString_rsGallery);
?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
    
'UploadFolder' => "../../../images/gallery/",
    
'FileName' => "[FileName]",
    
'DefaultFileName' => "",
    
'ResizeType' => "3",
    
'ResizeWidth' => "",
    
'ResizeHeight' => "525",
    
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1_2 Start
$WA_UploadResult1_Params["WA_UploadResult1_2"] = array(
    
'UploadFolder' => "../../../images/gallery/thumbs/",
    
'FileName' => "[FileName]",
    
'DefaultFileName' => "",
    
'ResizeType' => "3",
    
'ResizeWidth' => "150",
    
'ResizeHeight' => "225",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_2 End
// WA_UploadResult1 Params End
?>
<?php
// WA_UploadResult2 Params Start
$WA_UploadResult2_Params = array();
// WA_UploadResult2_1 Start
$WA_UploadResult2_Params["WA_UploadResult2_1"] = array(
    
'UploadFolder' => "../../../images/gallery/",
    
'FileName' => "[FileName]",
    
'DefaultFileName' => "",
    
'ResizeType' => "3",
    
'ResizeWidth' => "120",
    
'ResizeHeight' => "525",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult2_1 End
// WA_UploadResult2_2 Start
$WA_UploadResult2_Params["WA_UploadResult2_2"] = array(
    
'UploadFolder' => "../../../images/gallery/thumbs/",
    
'FileName' => "[FileName]",
    
'DefaultFileName' => "",
    
'ResizeType' => "3",
    
'ResizeWidth' => "120",
    
'ResizeHeight' => "225",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult2_2 End
// WA_UploadResult2 Params End
?>
<?php
// WA_UploadResult3 Params Start
$WA_UploadResult3_Params = array();
// WA_UploadResult3_1 Start
$WA_UploadResult3_Params["WA_UploadResult3_1"] = array(
    
'UploadFolder' => "../../../images/gallery/",
    
'FileName' => "[FileName]",
    
'DefaultFileName' => "",
    
'ResizeType' => "3",
    
'ResizeWidth' => "120",
    
'ResizeHeight' => "525",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult3_1 End
// WA_UploadResult3_2 Start
$WA_UploadResult3_Params["WA_UploadResult3_2"] = array(
    
'UploadFolder' => "../../../images/gallery/thumbs/",
    
'FileName' => "[FileName]",
    
'DefaultFileName' => "",
    
'ResizeType' => "3",
    
'ResizeWidth' => "120",
    
'ResizeHeight' => "225",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult3_2 End
// WA_UploadResult3 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct
("WA_UploadResult1");
if(isset(
$_POST["Insert_x"])){
    
WA_DFP_UploadFiles("WA_UploadResult1""image_0""2""[NewFileName]_[Increment]""JPG:70"$WA_UploadResult1_Params);
}
?>
<?php
WA_DFP_SetupUploadStatusStruct
("WA_UploadResult2");
if(isset(
$_POST["Insert_x"])){
    
WA_DFP_UploadFiles("WA_UploadResult2""image_1""2""[NewFileName]_[Increment]""JPG:70"$WA_UploadResult2_Params);
}
?>
<?php
WA_DFP_SetupUploadStatusStruct
("WA_UploadResult3");
if(isset(
$_POST["Insert_x"])){
    
WA_DFP_UploadFiles("WA_UploadResult3""image_2""2""[NewFileName]_[Increment]""JPG:70"$WA_UploadResult3_Params);
}
?>
<?php
// WA DataAssist Multiple Inserts
if (isset($_POST["Insert_x"])) // Trigger
{
  if (!
session_id()) session_start();
  
$WA_loopedFields = array("id""location""imagetext");
  
$WA_connection $dbCMS;
  
$WA_table "tblGallery";
  
$WA_redirectURL "tblgallery_ResultsMultiTest.php";
  
$WA_keepQueryString false;
  
$WA_fieldNamesStr "id|location|imagethumb|imagelarge|imagetext";
  
$WA_columnTypesStr "none,none,NULL|',none,''|',none,''|',none,''|',none,''";
  
$WA_insertIfNotBlank "";
  
$WA_fieldNames explode("|"$WA_fieldNamesStr);
  
$WA_columns explode("|"$WA_columnTypesStr);
  
$WA_connectionDB $database_dbCMS;
  
$WA_multipleInsertCounter 0;
  
mysql_select_db($WA_connectionDB$WA_connection);
  while (
WA_AB_checkMultiInsertLoopedFieldsExist($WA_loopedFields$WA_multipleInsertCounter)) {
    if (
$WA_insertIfNotBlank == "" || WA_AB_checkLoopedFieldsNotBlank(array($WA_insertIfNotBlank), $WA_multipleInsertCounter)) {
      
$WA_fieldValuesStr "".WA_AB_getLoopedFieldValue("id"$WA_multipleInsertCounter)  ."" "|" "".WA_AB_getLoopedFieldValue("location"$WA_multipleInsertCounter)  ."" "|" "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" "|" "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" "|" "".WA_AB_getLoopedFieldValue("imagetext"$WA_multipleInsertCounter)  ."";
      
$WA_fieldValues explode("|"$WA_fieldValuesStr);
      
$insertParamsObj WA_AB_generateInsertParams($WA_fieldNames$WA_columns$WA_fieldValues, -1);
      
$WA_Sql "INSERT INTO `" $WA_table "` (" $insertParamsObj->WA_tableValues ") VALUES (" $insertParamsObj->WA_dbValues ")";
      
$MM_editCmd mysql_query($WA_Sql$WA_connection) or die(mysql_error());
    }
    
$WA_multipleInsertCounter++;
  }
  if (
$WA_redirectURL != "")  {
    if (
$WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
      
$WA_redirectURL .= ((strpos($WA_redirectURL'?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
    }
    
header("Location: ".$WA_redirectURL);
  }
}
?><?php
    
// RepeatSelectionCounter_1 Initialization
    
$RepeatSelectionCounter_1 0;
    
$RepeatSelectionCounterBasedLooping_1 false;
    
$RepeatSelectionCounter_1_Iterations "3";
?>



Thanks,
Troy

Sign in to reply to this post

Eric Mittman

You will only be able to bind the repeated file field in the multi insert interface, there is no choice to insert an alternate value. It might be possible to get your DFP upload bindings inserted with the multi insert but it would require making changes to the WA_AB_getLoopedFieldValue function call. This is not something I would suggest doing unless you are experienced in ASP VB coding.

The alternative would be to use update server behaviors to go back and update each of the records to add in the bindings you need from the available upload bindings.

Sign in to reply to this post

troyd

Ok., now I'm really confused. ASP???
I'm going to go through each step, little by little because I'm sure it's me that is missing something obvious. But the ASP VP thing is throwing me. How does that work with PHP?

TroyD

Sign in to reply to this post

Eric Mittman

My apologies for the confusion, I got part of this post mixed up with another that was working in ASP VB.

The idea is the same with php though, the server behavior is only designed to work with posted form elements, so dynamically created bindings are not usable with the multi insert without adjusting the function used.

The alternative is to add in update server behaviors, one for each record you inserted. In these updates you just add the file bindings that are missing from the inserted records.

Sign in to reply to this post

troyd

No problem. That makes sense. I was wondering how the ASP VB was going to tie in.

So just to clarify, the Update server behavior is used on the Insert page?

What I have going on here is a simple insert I created for a client a while back. It is just a simple image gallery. But they say it takes too long to upload one image at a time. And since there is a "Image Title" and an "Image Description", I need them to each be their own record. So I can't just put several uploads in one form.

So on the insert form I have;
id, imagetitle, imagedesc, imagethumb.

Is there documentation on using the update server behavior in this way?

TroyD

Sign in to reply to this post

Eric Mittman

We do not have any documentation for using the update like this. The problem is that the DFP upload server behavior is just not compatible with the multi insert or multi update server behaviors. Due to this you will not be able to insert the image information for each record when the record is inserted. To get around this you would add in update server behaviors on this page to go back and update the records that you just inserted. In order to update the record you will need to have an identifier for that record, so you would need to use the values from the form as the field to base the update on rather than the id. This is not a simple scenario to deal with and will require some extra effort to get into place. Please post back with any specific questions about any part of this and I will do my best to explain it and help you get it going.

Sign in to reply to this post

troyd

Eric,

Just curious. Does the PowerGallery solution already have this built into it?

TroyD

Sign in to reply to this post

anonymous

Troy,

Are you just looking for multiple image uploads, say, for a photo gallery?

If so, yes, PowerGallery does that. I have also seen on these forums where WebAssist has talked adding Multiple Uploads to the next version of Digital File Pro because it has been requested quite a bit (I believe in the wishlist section).

I am still using the ADDT Multiple Image uploaded (which uses Flash to upload the files) as I have found that it still works even with the latest release of PHP (some of the ADDT thing do not work now but luckily that one still does).

Regards,

Brian

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...