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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to create the image filename as the ID?

Thread began 2/15/2010 11:08 am by diego.zuppa399503 | Last modified 2/17/2010 1:07 pm by Jason Byrnes | 795 views | 5 replies |

diego.zuppa399503

How to create the image filename as the ID?

Hi!
I write you from Italy, I hope you will understand me...
This is my problem:
I want that the uploaded file name (foto1) become the same of the ID record name (id_automobile).
I'm using DFP & Data Assist.
I send you the page code so you can see it.
Thank you for your help.
Diego

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

Jason ByrnesWebAssist

You can only do that if the file upload occurs after the record is inserted, you will have to manually move the upload coded o that it is after the insert record code.


Then in the upload file server behavior, click the lightning bolt next to file name and select the WADA_Insert_automobili session variable that is created by the insert record server behavior.

Sign in to reply to this post

diego.zuppa399503

Thanks!
Now the file is loaded in the folder with the right name, but the page gives me the following error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\xampp\htdocs\new-junior-team\admin\automobili_Inserisci.php:81) in C:\Program Files\xampp\htdocs\new-junior-team\admin\automobili_Inserisci.php on line 99

and the db is not updated.
This is the code:

<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $newjuniorteam;
$WA_table = "automobili";
$WA_sessionName = "WADA_Insert_automobili";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "id_automobile";
$WA_fieldNamesStr = "id_marca|id_stato|nome|descrizione|prezzo|foto1|foto2|foto3|attivo";
$WA_fieldValuesStr = "".((isset($_POST["id_marca"]))?$_POST["id_marca"]:"") ."" . "|" . "".((isset($_POST["id_stato"]))?$_POST["id_stato"]:"") ."" . "|" . "".((isset($_POST["nome"]))?$_POST["nome"]:"") ."" . "|" . "".((isset($_POST["descrizione"]))?$_POST["descrizione"]:"") ."" . "|" . "".((isset($_POST["prezzo"]))?$_POST["prezzo"]:"") ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."" . "|" . "".((isset($_POST["foto2"]))?$_POST["foto2"]:"") ."" . "|" . "".((isset($_POST["foto3"]))?$_POST["foto3"]:"") ."" . "|" . "".((isset($_POST["attivo"]))?$_POST["attivo"]:"") ."";
$WA_columnTypesStr = "none,none,NULL|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,0";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_newjuniorteam;
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_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../upload/",
'FileName' => "".$_SESSION['WADA_Insert_automobili'] ."",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "foto1", "0", "", "false", $WA_UploadResult1_Params);
}
?>

Thanks for the help!
Diego

Sign in to reply to this post

Jason ByrnesWebAssist

see the following for information on the headers already sent error message:
148/


Please add the original php file to zip archive and end the zip archive in your response instead of pasting the code.

Sign in to reply to this post

diego.zuppa399503

Here is the original php

Fixed "headers already sent" problem

There remains the problem that the column of the file upload (foto1) is not updated into db

Thanks again for the help
Diego

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

Jason ByrnesWebAssist

since you are using the value of the id_automobile column for the files name, there is no need to store the name in the data base. it is also not possible since the file is not uploaded until after the record is inserted.

Sign in to reply to this post

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