close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Problem of losing image with update

Thread began 2/03/2010 9:49 am by ant.knott394719 | Last modified 2/12/2010 3:52 pm by zuffster370186 | 1575 views | 14 replies |

ant.knott394719

Problem of losing image with update

I've been using the insert/update tutorial to get images to upload on the insert page using DFP and then following the instructions for the update page. Insert works great but i'm losing my images on the update page. I've looked through the forum and i've seen that several other people have struggled with this. Anyway, i understand the concept, i've changed the relevant field to hidden and i've clicked on the lightning thunderbolt next to the default file and added the thumb1 field but it still isn't forwarding the image name onto my update page and so i'm losing the image. I assume my code is wrong somewhere, can someone have a quick look for me and see if they can spot any obvious errors. Thanks.
There are 4 image fields ItemThumb1, Thumb2, Thumb3, Thumb4. There was a fifth called ItemImage but i removed this to try to make things simpler.

<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../profilethumbs/",
'FileName' => "[FileName]",
'DefaultFileName' => "".((isset($_FILES["ItemThumb1"]))?$_FILES["ItemThumb1"]["name"]:"") ."",
'ResizeType' => "0",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 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' => "../profilethumbs/",
'FileName' => "[FileName]",
'DefaultFileName' => "".((isset($_FILES["ItemThumb2"]))?$_FILES["ItemThumb2"]["name"]:"") ."",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult2_1 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' => "../profilethumbs/",
'FileName' => "[FileName]",
'DefaultFileName' => "".((isset($_FILES["ItemThumb3"]))?$_FILES["ItemThumb3"]["name"]:"") ."",
'ResizeType' => "0",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult3_1 End
// WA_UploadResult3 Params End?>
<?php
// WA_UploadResult4 Params Start
$WA_UploadResult4_Params = array();
// WA_UploadResult4_1 Start
$WA_UploadResult4_Params["WA_UploadResult4_1"] = array(
'UploadFolder' => "../profilethumbs/",
'FileName' => "[FileName]",
'DefaultFileName' => "".((isset($_FILES["ItemThumb4"]))?$_FILES["ItemThumb4"]["name"]:"") ."",
'ResizeType' => "0",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult4_1 End
// WA_UploadResult4 Params End
?>
<?php?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "ItemThumb1", "0", "", "true", $WA_UploadResult1_Params);
}
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult2");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult2", "ItemThumb2", "0", "", "true", $WA_UploadResult2_Params);
}
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult3");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult3", "ItemThumb3", "0", "", "true", $WA_UploadResult3_Params);
}
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult4");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult4", "ItemThumb4", "0", "", "true", $WA_UploadResult4_Params);
}
?>
<?php?>
<?php?>
<?php?>
<?php

Sign in to reply to this post

CraigRBeta Tester

have you tried using the debug ?

here is a thread with instructions to stop the page redirecting after update, and showing errors.

this should help determine if the image is uploading

showthread.php?t=8858&highlight=debug

check out post #2 by Jason

Sign in to reply to this post

Jason ByrnesWebAssist

The problem is that the Default file Name setting is using the $_FILES collection, not the hidden form element:

'DefaultFileName' => "".((isset($_FILES["ItemThumb2"]))?$_FILES["ItemThumb2"]["name"]:"") ."",

assuming the hidden form element where named "hiddenItemThumb2" the above code should look like:
'DefaultFileName' => "".((isset($_POST["hiddenItemThumb2"]))?$_POST["hiddenItemThumb2"]:"") ."",

Sign in to reply to this post

ant.knott394719

angriest society

Hi there,
Thanks for the help so far but after adding the correct code in the default file i re-tested and got the same result as before so i had a go at the debug as mentioned in the thread suggested and when i clicked update it didn't recognise the file.

The page had the following message.

Not Found
The requested URL /Lat/Admin/WA_DFP_AllUploadsDebug() was not found on this server.
Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2 Server at localhost Port 80

Have i done the hidden form field correctly.

My code for the form elements looks like this.

<th class="WADADataTableHeader">Thumb1:</th>
<td class="WADADataTableCell"><input type="hidden" name="ItemThumb1" id="ItemThumb1" value="<?php echo(str_replace('"', '&quot;', $row_WADAitems['ItemThumb1'])); ?>" size="25" />
<label for="ItemThumb1"></label>
<input type="file" name="ItemThumb1" id="ItemThumb1" />
</tr>
<tr>
<th class="WADADataTableHeader">Thumb2:</th>
<td class="WADADataTableCell"><input type="hidden" name="ItemThumb2" id="ItemThumb2" value="<?php echo(str_replace('"', '&quot;', $row_WADAitems['ItemThumb2'])); ?>" size="25" />
<label for="ItemThumb2"></label>
<input type="file" name="ItemThumb2" id="ItemThumb2" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Thumb3:</th>
<td class="WADADataTableCell"><input type="hidden" name="ItemThumb3" id="ItemThumb3" value="<?php echo(str_replace('"', '&quot;', $row_WADAitems['ItemThumb3'])); ?>" size="25" />
<label for="ItemThumb3"></label>
<input type="file" name="ItemThumb3" id="ItemThumb3" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Thumb4:</th>
<td class="WADADataTableCell"><input type="hidden" name="ItemThumb4" id="ItemThumb4" value="<?php echo(str_replace('"', '&quot;', $row_WADAitems['ItemThumb4'])); ?>" size="25" />
<label for="ItemThumb4"></label>
<input type="file" name="ItemThumb4" id="ItemThumb4" /></td>
</tr>
</table>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Update" id="Update" value="Update" alt="Update" src="../WA_DataAssist/images/Poppy/Elemental_update.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="items_Results.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="../WA_DataAssist/images/Poppy/Elemental_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADAUpdateRecordID" type="hidden" id="WADAUpdateRecordID" value="<?php echo(rawurlencode($row_WADAitems['ItemID'])); ?>" />
</div>
</form>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_WADAitems == 0) { // Show if recordset empty ?>
<div class="WADANoResults">
<div class="WADANoResultsMessage">No record found.</div>
</div>
<?php } // Show if recordset empty ?>
</div>
</div>
</div>
<div id="footer"><a href="../contactus.php">Contact us</a> | <a href="../sitemap.php">Sitemap</a> | <a href="../termsofuse.php">Terms of Use</a> | <a href="../privacypolicy.php">Privacy policy</a> | <a href="../shoppingcart.php">Shopping cart</a> | <a href="../checkout.php">Checkout</a> | <a href="../registration.php">Registration</a> | <a href="../Profile_Search.php">Search</a> | <a href="../visitors_LogOut.php">Logout</a></div>
</div>

</body>
</html>
<?php
mysql_free_result($WADAitems);
?>
<?php
mysql_free_result($WADADynListcountries);
?>

Sign in to reply to this post

ant.knott394719

Update problem

My only other worry is that i moved the image form fields to the bottom of the form and removed one of the fields completely (itemImage). The items recordset has the image items in there original location and includes ItemImage as below. I don't know if this is effecting the upload working or not. Now, when i click on the WA Upload File in the server behaviours i get the message.

One of your server side values is incorrect. Check for inconsistencies. So there's probably something wrong somewhere. Any help would be gratefully received.

The code looks like this:

// WA Application Builder Update
if (isset($_POST["Update_x"])) // Trigger
{
$WA_connection = $latinsite;
$WA_table = "items";
$WA_redirectURL = "items_Detail.php?ItemID=".((isset($_POST["WADAUpdateRecordID"]))?$_POST["WADAUpdateRecordID"]:"") ."";
$WA_keepQueryString = false;
$WA_indexField = "ItemID";
$WA_fieldNamesStr = "ItemID|ItemCatID|ItemCode|ItemFirstName|ItemLastName|ItemAddress|ItemCity|ItemState|ItemCountry|ItemCountryID|ItemShortDesc|ItemLongDesc|ItemPrice|ItemThumb1|ItemThumb2|ItemThumb3|ItemThumb4|ItemImage|ItemEmail|ItemPhone|ItemMobile|ItemAge|ItemAgeID|ItemHeight|ItemHeightID|ItemWeight|ItemStar|ItemRelocate|ItemEnglish";
$WA_fieldValuesStr = "".((isset($_POST["ItemID"]))?$_POST["ItemID"]:"") ."" . "|" . "".((isset($_POST["ItemCatID"]))?$_POST["ItemCatID"]:"") ."" . "|" . "".((isset($_POST["ItemCode"]))?$_POST["ItemCode"]:"") ."" . "|" . "".((isset($_POST["ItemFirstName"]))?$_POST["ItemFirstName"]:"") ."" . "|" . "".((isset($_POST["ItemLastName"]))?$_POST["ItemLastName"]:"") ."" . "|" . "".((isset($_POST["ItemAddress"]))?$_POST["ItemAddress"]:"") ."" . "|" . "".((isset($_POST["ItemCity"]))?$_POST["ItemCity"]:"") ."" . "|" . "".((isset($_POST["ItemState"]))?$_POST["ItemState"]:"") ."" . "|" . "".((isset($_POST["ItemCountry"]))?$_POST["ItemCountry"]:"") ."" . "|" . "".((isset($_POST["ItemCountryID"]))?$_POST["ItemCountryID"]:"") ."" . "|" . "".((isset($_POST["ItemShortDesc"]))?$_POST["ItemShortDesc"]:"") ."" . "|" . "".((isset($_POST["ItemLongDesc"]))?$_POST["ItemLongDesc"]:"") ."" . "|" . "".((isset($_POST["ItemPrice"]))?$_POST["ItemPrice"]:"") ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult2"]["serverFileName"] ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult3"]["serverFileName"] ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult4"]["serverFileName"] ."" . "|" . "".((isset($_FILES["ItemImage"]))?$_FILES["ItemImage"]["name"]:"") ."" . "|" . "".((isset($_POST["ItemEmail"]))?$_POST["ItemEmail"]:"") ."" . "|" . "".((isset($_POST["ItemPhone"]))?$_POST["ItemPhone"]:"") ."" . "|" . "".((isset($_POST["ItemMobile"]))?$_POST["ItemMobile"]:"") ."" . "|" . "".((isset($_POST["ItemAge"]))?$_POST["ItemAge"]:"") ."" . "|" . "".((isset($_POST["ItemAgeID"]))?$_POST["ItemAgeID"]:"") ."" . "|" . "".((isset($_POST["ItemHeight"]))?$_POST["ItemHeight"]:"") ."" . "|" . "".((isset($_POST["ItemHeightID"]))?$_POST["ItemHeightID"]:"") ."" . "|" . "".((isset($_POST["ItemWeight"]))?$_POST["ItemWeight"]:"") ."" . "|" . "".((isset($_POST["ItemStar"]))?$_POST["ItemStar"]:"") ."" . "|" . "".((isset($_POST["ItemRelocate"]))?$_POST["ItemRelocate"]:"") ."" . "|" . "".((isset($_POST["ItemEnglish"]))?$_POST["ItemEnglish"]:"") ."";
$WA_columnTypesStr = "none,none,NULL|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|',none,''|',none,''|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|',none,''|none,none,NULL|',none,''|',none,''|',none,''|',none,''";
$WA_comparisonStr = "=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=|=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);

$WA_where_fieldValuesStr = "".((isset($_POST["WADAUpdateRecordID"]))?$_POST["WADAUpdateRecordID"]:"") ."";
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);

$WA_connectionDB = $database_latinsite;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
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);
}
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

Please compress the php file into a zip archive and attach the zip file so I can see the complete code.

Sign in to reply to this post

ant.knott394719

update images issue - zip attached

Good idea, zip is attached.

By the way i discovered yesterday that the message 'One of your server side values is incorrect. Check for inconsistencies' that appears when clicking on the WA update thumb1 server behaviour only appears if i change the default file name code to the following:


'DefaultFileName' => "".((isset($_POST["hiddenItemThumb1"]))?$_POST["hiddenItemThumb1"]:"") ."",

I have therefore removed this code for the time being.
Let me know if you can see any other problems. Thanks for this.

Attached Files
items_Update.php.zip
Sign in to reply to this post

Jason ByrnesWebAssist

The hidden form elements have the same name as the file fields. you must give a unique name to each form element. if you have two form elements that are named the same, the value for the second one will over ride the first one.


Rename the hidden form elements to have a unique name, then in the DFP Wizard, click the lightning bolt next to default file name and select the correct hidden form element.

Sign in to reply to this post

ant.knott394719

Success

Fantastic. I changed the names and it now works perfectly. It's seems so easy once you know how, anyway thanks for all the help, much appreciated.

Sign in to reply to this post

office377308

focus problem

I had a problem with the last step: The docu says:
20. From the Server Behaviors panel, double-click on the Update Record option.
21. Click Next to proceed to step 2.
22. Select the column you applied the file field to.
23. Click the value lightning bolt.
24. Expand the WA Upload File option for your column.
25. Choose Server File Name.

In my case 24. is called:
WA Upload Files (name_of_form_field)
mind, there is also another one called
WA Upload Files Global Status (which would be the wrong choice)

And there is an ongoing focus problem which only happens with WebAssist Extensions (Windows 7 / CS3).

According to the same description further up:
15. Choose the Default file value lightning bolt.
16. Expand the WADAUpdateForm option.
17. Choose the form field you set to hidden earlier.
18. Click OK.

in 17. I chose the Default file as described. Later I checked the code and found:

'DefaultFileName' => "",

So, it did not accept the choice,
a choice that I had to put manually after I found that it did not work:

'DefaultFileName' => "".((isset($_POST["field_name"]))?$_POST["field_name"]:"") ."",

This never happens in Dreamweaver's entry fields i.e. Server Behaviours like in "Recordset" or those of any other Extension producer.

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