close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

inserting image file name and server file name into db

Thread began 10/01/2009 4:12 am by julie.skelton390139 | Last modified 11/03/2009 3:09 pm by Jason Byrnes | 8909 views | 12 replies |

julie.skelton390139

inserting image file name and server file name into db

I have created the admin pages using DataAssist and set up an image upload from the insert record page using DFP2. I followed the instructions in the help pdf dfp_da_insert_update_ht.pdf However the instructions do not give full details of how/what to put in the server behavior field under the column for my image thumbnail field in the database. Setting the value to <?php echo $WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]; ?> works great for the main image, however as I have set up the upload to work from one upload automatically creating the thumb image (renaming the file to picname_thumb.jpg) I don't know what to enter for the value of the server behavior to make it add the _thumb bit which is automatically added.

So to summarize the pic is uploading correctly and automatically creatiing a _thumb version from the one upload, and the file name is being inserted into the database main pic field correctly however I don't know how to get it to add the _thumb filename into the thumb filename field of the database

Sign in to reply to this post

Jason ByrnesWebAssist

When you set digital File Pro to upload multiple copies of a file to different folders, there are Server File name bindings created in the WA Uploaded Files (File Filed name) bindings group.
Say for example that I have a Thumbs and Large folder that I am uploading to, the Bindings groups will contain bindings titled:
Thumbs[FileName]: Server File Name
large[FileName]: Server File Name


For the database column you wish to store the thumbnail in, bind to the Thumbs[FileName]: Server File Name, for the column you wish to store the large image name, use the large[FileName]: Server File Name binding.

Sign in to reply to this post

julie.skelton390139

I could not find Thumbs[FileName]: Server File Name from the image when I double click on Insert Record from Server Behaviours (Page 2 of options > then clicked the thumb column and lightening bolt > WA Upload files - it only lists Server File Name for the main image not the thumb.

I have worked around it for now making it call the thumbnail version the same as the main image eg [filename] instead of [filename]_thumb, but it places it in a different directory. Need to work on the update page now so not sure how this will work with your instructions as it mentions the hidden field etc??

Sign in to reply to this post

Jason ByrnesWebAssist

I have created a support ticket for you so we can look into the problem, to view and edit your support ticket, please log into your support history:

supporthistory.php?

Sign in to reply to this post

troyd

I am having the same issue. What was the resolve for this?

Everything is uploading and creating the large image and thumb but the large image filename is written to both the large and thumb column in my table.

I don't see any thumb server file name in the bindings for that column.

Thanks,
TroyD

Sign in to reply to this post

troyd

I am not having any luck figuring this out. Still don't have a server file name choice for the thumbs.
Here are some more details. First, I'm using DFP 2.0.2.
I have one WA upload behavior with two images being generated. A large and a thumb. I will paste my code below.

Upload behavior.

php:
<?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]_large",
    
'DefaultFileName' => "",
    
'ResizeType' => "4",
    
'ResizeWidth' => "700",
    
'ResizeHeight' => "525",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1_2 Start
$WA_UploadResult1_Params["WA_UploadResult1_2"] = array(
    
'UploadFolder' => "images/gallery/thumbs/",
    
'FileName' => "[FileName]_thumb",
    
'DefaultFileName' => "",
    
'ResizeType' => "4",
    
'ResizeWidth' => "300",
    
'ResizeHeight' => "225",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_2 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct
("WA_UploadResult1");
if(isset(
$_POST["Submit"])){
    
WA_DFP_UploadFiles("WA_UploadResult1""image""0""""JPG:70"$WA_UploadResult1_Params);
}
?>



Insert behavior. (Data Assist 2.0.5)

php:
<?php 

// WA Application Builder Insert
if (isset($_POST["Submit"])) // Trigger
{
  
$WA_connection $localhost;
  
$WA_table "tblGallerysp";
  
$WA_sessionName "tblGallerysp_id";
  
$WA_redirectURL "results.php";
  
$WA_keepQueryString false;
  
$WA_indexField "id";
  
$WA_fieldNamesStr "id|imagethumb|imageorig|labeltext";
  
$WA_fieldValuesStr "".((isset($_POST["id"]))?$_POST["id"]:"")  ."" "|" "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" "|" "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" "|" "".((isset($_POST["imagelabel"]))?$_POST["imagelabel"]:"")  ."";
  
$WA_columnTypesStr "none,none,NULL|',none,''|',none,''|',none,''";
  
$WA_fieldNames explode("|"$WA_fieldNamesStr);
  
$WA_fieldValues explode("|"$WA_fieldValuesStr);
  
$WA_columns explode("|"$WA_columnTypesStr);
  
$WA_connectionDB $database_localhost;
  
mysql_select_db($WA_connectionDB$WA_connection);
  if (!
session_id()) session_start();
  
$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());
  
$_SESSION[$WA_sessionName] = mysql_insert_id();
  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);
  }
}
?>



Should I just change this line in the insert?...

php:
$WA_fieldValuesStr = "".((isset($_POST["id"]))?$_POST["id"]:"")  ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"]  ."" . "|" . "".((isset($_POST["imagelabel"]))?$_POST["imagelabel"]:"")  ."";



To...

php:
$WA_fieldValuesStr = "".((isset($_POST["id"]))?$_POST["id"]:"")  ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1_1"]["serverFileName"]  ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1_2"]["serverFileName"]  ."" . "|" . "".((isset($_POST["imagelabel"]))?$_POST["imagelabel"]:"")  ."";



I'll try it, but is this correct?

Thanks,
TroyD

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, using:
$WA_DFP_UploadStatus["WA_UploadResult1_1"]["serverFileName"]

Should get the large file name

and:
$WA_DFP_UploadStatus["WA_UploadResult1_2"]["serverFileName"]

should return the thumbnail file name.

Sign in to reply to this post

troyd

Thanks Jason,
I tried this and now I'm getting an error. Plus, when I look in the insert wizard, it has my server file names mismatched. I can't see what the problem is. Can you take a look?

Error after inserting record with upload.

Notice: Undefined index: WA_UploadResult1_1 in /Applications/MAMP/htdocs/SandboxPHP/lightbox/insert2.php on line 81

Notice: Undefined index: WA_UploadResult1_2 in /Applications/MAMP/htdocs/SandboxPHP/lightbox/insert2.php on line 81

Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/SandboxPHP/lightbox/insert2.php:81) in /Applications/MAMP/htdocs/SandboxPHP/lightbox/insert2.php on line 97


Here is my new line (81) it's referencing.

php:
$WA_fieldValuesStr = "".((isset($_POST["id"]))?$_POST["id"]:"")  ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1_1"]["serverFileName"]  ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1_2"]["serverFileName"]  ."" . "|" . "".((isset($_POST["imagelabel"]))?$_POST["imagelabel"]:"")  ."";



I don't see any extra spaces in my php. The problems is most likely staring my in the face.

OH, one other detail. Now, it's not writing anything into the image columns. Which stands to reason, but I figured I would add that here.

Thanks,
TroyD

Sign in to reply to this post

Jason ByrnesWebAssist

Please send the full php page so I can see the code in context, not just the one line.

Sign in to reply to this post

troyd

Sure, here you go. Hope it was ok I pasted it here.

php:
<?php require_once('../Connections/localhost.php'); ?>

<?php 
require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php 
require_once("../WA_DigitalFilePro/HelperPHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

mysql_select_db($database_localhost$localhost);
$query_rsGallerySP "SELECT * FROM tblGallerysp ORDER BY id DESC";
$rsGallerySP mysql_query($query_rsGallerySP$localhost) or die(mysql_error());
$row_rsGallerySP mysql_fetch_assoc($rsGallerySP);
$totalRows_rsGallerySP mysql_num_rows($rsGallerySP);?>
<?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]_large",
    
'DefaultFileName' => "",
    
'ResizeType' => "4",
    
'ResizeWidth' => "700",
    
'ResizeHeight' => "525",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1_2 Start
$WA_UploadResult1_Params["WA_UploadResult1_2"] = array(
    
'UploadFolder' => "images/gallery/thumbs/",
    
'FileName' => "[FileName]_thumb",
    
'DefaultFileName' => "",
    
'ResizeType' => "4",
    
'ResizeWidth' => "300",
    
'ResizeHeight' => "225",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_2 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct
("WA_UploadResult1");
if(isset(
$_POST["Submit"])){
    
WA_DFP_UploadFiles("WA_UploadResult1""image""0""""JPG:70"$WA_UploadResult1_Params);
}
?>
<?php 
// WA Application Builder Insert
if (isset($_POST["Submit"])) // Trigger
{
  
$WA_connection $localhost;
  
$WA_table "tblGallerysp";
  
$WA_sessionName "tblGallerysp_id";
  
$WA_redirectURL "results.php";
  
$WA_keepQueryString false;
  
$WA_indexField "id";
  
$WA_fieldNamesStr "id|imageorig|imagethumb|labeltext";
  
$WA_fieldValuesStr "".((isset($_POST["id"]))?$_POST["id"]:"")  ."" "|" "".$WA_DFP_UploadStatus["WA_UploadResult1_1"]["serverFileName"]  ."" "|" "".$WA_DFP_UploadStatus["WA_UploadResult1_2"]["serverFileName"]  ."" "|" "".((isset($_POST["imagelabel"]))?$_POST["imagelabel"]:"")  ."";
  
$WA_columnTypesStr "none,none,NULL|',none,''|',none,''|',none,''";
  
$WA_fieldNames explode("|"$WA_fieldNamesStr);
  
$WA_fieldValues explode("|"$WA_fieldValuesStr);
  
$WA_columns explode("|"$WA_columnTypesStr);
  
$WA_connectionDB $database_localhost;
  
mysql_select_db($WA_connectionDB$WA_connection);
  if (!
session_id()) session_start();
  
$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());
  
$_SESSION[$WA_sessionName] = mysql_insert_id();
  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);
  }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Gallery Insert</title>
<style type="text/css">
<!--
#galleryresultscontainer {
    width: 900px;
    margin-right: auto;
    margin-left: auto;
    text-align: center;
}
.thumbswrap {
    width: 200px;
    text-align: center;
    padding: 5px;
    float: left;
}
.labeltext {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    margin-top: 2px;
    float: left;
    width: 100%;
    background-color: #CDC9EB;
}
#formwrap {
    width: 900px;
    margin-right: auto;
    margin-left: auto;
    text-align: center;
}
#formwrap label {
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    margin-right: 5px;
}
-->
</style>
</head>
<body>
<div id="formwrap">
  <form  action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <input name="id" type="hidden" id="id" value="" />
    <label>Choose Image:
    <input type="file" name="image" id="image" />
    </label>
    <label>Image Label:
    <input name="imagelabel" type="text" id="imagelabel" size="45" />
    </label>
    <input type="submit" name="Submit" id="Submit" value="Submit" />
  </form>
</div>
<?php do { ?>
  <div id="galleryresultscontainer">
    <?php if ($totalRows_rsGallerySP 0) { // Show if recordset not empty ?>
      <div class="thumbswrap"><img  src="images/gallery/thumbs/<?php echo $row_rsGallerySP['imagethumb']; ?>" alt="" name="imagepreview" width="200" id="imagepreview" />
        <div class="labeltext"><?php echo $row_rsGallerySP['labeltext']; ?></div>
        <div class="labeltext"><a href="delete.php?id=<?php echo(rawurlencode($row_rsGallerySP['id'])); ?>">Delete</a></div>
      </div>
      <?php // Show if recordset not empty ?>
  </div>
  <?php } while ($row_rsGallerySP mysql_fetch_assoc($rsGallerySP)); ?>
</body>
</html>
<?php
mysql_free_result
($rsGallerySP);
?>


Thanks so much,
TroyD

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