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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

insert photo on with new record

Thread began 1/20/2011 9:43 pm by davidp420108 | Last modified 1/21/2011 1:09 pm by Jason Byrnes | 979 views | 9 replies |

davidp420108

insert photo on with new record

All my other problems have stemmed form this. a new thread seemed correct since i may be able to ask a clear question now.

I want to upload a picture that goes to a dynamically generated folder. the folder name is the same as the record id that is autogenerated.

how do i get the new id number to create the folder prior to inserting an image into it?

I am stumped...the only thing i can seem to find is using some version of GETLAST, but everything I read says this can cause problems on a mutliuser environment.


$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "./".$_SESSION['Dealer_Name'] ."/images/".$_POST["Inventory_ID"] ."/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );



Inventory_ID is the the unique auto incrementing number i want to use for the new folder.

can this be done simultaneously(in the eyes if the user)?

Thanks,

David

Sign in to reply to this post

Jason ByrnesWebAssist

This is a bit of a quandary. You cant reliably know the ID that will be used for the record untill the insert has taken place.

I think to do this you will need to use a three step process:

Insert Record
Upload Image
Update record

In the data assist insert behavior, there is a setting called Store As, this stores the ID of the record that was inserted into a session variable.

You could insert the record with all of the other information from the form, use the Session Created by the Insert Record behavior in the File upload path, then Update the record to store the uploaded file name.

Make sure that the Insert record behavior does not have a redirect set. you will probably need to rearrange the code for the behaviors to get into the right order and you'll also want to use the Cookies Toolkit unset session behavior to clear the session after the update has taken place.

Sign in to reply to this post

davidp420108

am understanding that this can be done on one page? it just needs to have the proper order of code?

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, it can all be done on one page, just as long as the code is in the correct order:

insert
upload
update

Sign in to reply to this post

davidp420108

almost there...just a little more help please.

<?php 
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $Auto_Sales;
$WA_table = "inventory_tbl";
$WA_sessionName = "WADA_Insert_inventory_tbl";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "Inventory_ID";
$WA_fieldNamesStr = "Dealer_Name|Price|Make|Model|Year|Engine|Drivetrain|Transmission|Mileage|Ext_Color|Int_Color|Body_Style|VIN|Stock_Number|Description|Date_Online|Expires|pwr_windows|pwr_locks|rear_slider|DVD|3rd_seat|premium_sound|leather|bed_liner|Dealer_TBL_Dealer_ID|Status|City|Contact_Phone";
$WA_fieldValuesStr = "".((isset($_POST["Dealer_Name"]))?$_POST["Dealer_Name"]:"") ."" . "|" . "".((isset($_POST["Price"]))?$_POST["Price"]:"") ."" . "|" . "".((isset($_POST["Make"]))?$_POST["Make"]:"") ."" . "|" . "".((isset($_POST["Model"]))?$_POST["Model"]:"") ."" . "|" . "".((isset($_POST["Year"]))?$_POST["Year"]:"") ."" . "|" . "".((isset($_POST["Engine"]))?$_POST["Engine"]:"") ."" . "|" . "".((isset($_POST["Drivetrain"]))?$_POST["Drivetrain"]:"") ."" . "|" . "".((isset($_POST["Transmission"]))?$_POST["Transmission"]:"") ."" . "|" . "".((isset($_POST["Mileage"]))?$_POST["Mileage"]:"") ."" . "|" . "".((isset($_POST["Ext_Color"]))?$_POST["Ext_Color"]:"") ."" . "|" . "".((isset($_POST["Int_Color"]))?$_POST["Int_Color"]:"") ."" . "|" . "".((isset($_POST["Body_Style"]))?$_POST["Body_Style"]:"") ."" . "|" . "".((isset($_POST["VIN"]))?$_POST["VIN"]:"") ."" . "|" . "".((isset($_POST["Stock_Number"]))?$_POST["Stock_Number"]:"") ."" . "|" . "".((isset($_POST["Description"]))?$_POST["Description"]:"") ."" . "|" . "".((isset($_POST["Date_Online"]))?$_POST["Date_Online"]:"") ."" . "|" . "".((isset($_POST["Expires"]))?$_POST["Expires"]:"") ."" . "|" . "".((isset($_POST["pwr_windows"]))?$_POST["pwr_windows"]:"") ."" . "|" . "".((isset($_POST["pwr_locks"]))?$_POST["pwr_locks"]:"") ."" . "|" . "".((isset($_POST["rear_slider"]))?$_POST["rear_slider"]:"") ."" . "|" . "".((isset($_POST["DVD"]))?$_POST["DVD"]:"") ."" . "|" . "".((isset($_POST["3rd_seat"]))?$_POST["3rd_seat"]:"") ."" . "|" . "".((isset($_POST["premium_sound"]))?$_POST["premium_sound"]:"") ."" . "|" . "".((isset($_POST["leather"]))?$_POST["leather"]:"") ."" . "|" . "".((isset($_POST["bed_liner"]))?$_POST["bed_liner"]:"") ."" . "|" . "".((isset($_POST["Dealer_TBL_Dealer_ID"]))?$_POST["Dealer_TBL_Dealer_ID"]:"") ."" . "|" . "".((isset($_POST["Status"]))?$_POST["Status"]:"") ."" . "|" . "".((isset($_POST["City"]))?$_POST["City"]:"") ."" . "|" . "".((isset($_POST["Contact_Phone"]))?$_POST["Contact_Phone"]:"") ."";
$WA_columnTypesStr = "',none,''|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|',none,NULL|',none,''|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_Auto_Sales;
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);
}
}
?>


<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["Insert_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "Photo_1_File", "0", "", "JPG:80", $WA_UploadResult1_Params);
}
?>

<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "./".$_SESSION['Dealer_Name'] ."/images/".$_POST["WADA_Insert_inventory_tbl"] ."/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End



it is not seeing the image name now. folder is creating but image not being saved.

Sign in to reply to this post

Jason ByrnesWebAssist

the session created by the insert record behavior is "WADA_Insert_inventory_tbl":
$WA_sessionName = "WADA_Insert_inventory_tbl";


in the upload behavior, you dont set the image name using the post in the upload folder:

php:
'UploadFolder' => "./".$_SESSION['Dealer_Name']  ."/images/".$_POST["WADA_Insert_inventory_tbl"]  ."/",



should be:

php:
'UploadFolder' => "./".$_SESSION['Dealer_Name']  ."/images/".$_SESSION["WADA_Insert_inventory_tbl"]  ."/",
Sign in to reply to this post

davidp420108

i made the changes. but the file is still not being saved. it saved the file when it was in the order:
upload
insert

but changing it to the order
insert
upload
update

has caused it to drop the filename. i do not see that it is saving the .jpg anywhere on the site at this time.

is a section of code "out of order"?

Thanks Jason

Sign in to reply to this post

Jason ByrnesWebAssist

yeah the upload code is out of order, the parameters should be first;

php:
<?php

// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
    
'UploadFolder' => "./".$_SESSION['Dealer_Name']  ."/images/".$_POST["WADA_Insert_inventory_tbl"]  ."/",
    
'FileName' => "[FileName]",
    
'DefaultFileName' => "",
    
'ResizeType' => "0",
    
'ResizeWidth' => "120",
    
'ResizeHeight' => "120",
    
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
?>
<?php
WA_DFP_SetupUploadStatusStruct
("WA_UploadResult1");
if(isset(
$_POST["Insert_x"])){
    
WA_DFP_UploadFiles("WA_UploadResult1""Photo_1_File""0""""JPG:80"$WA_UploadResult1_Params);
}
?>




also make sure not to leave spaces between the code blocks.

Sign in to reply to this post

davidp420108

thanks...works great now.

Your WA staff is really helpful. thanks again

David

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

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