View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

insert images to database

Thread began 3/16/2009 11:57 am by warrenphillips25336771 | Last modified 3/18/2009 10:58 am by warrenphillips25336771 | 2886 views | 8 replies

warrenphillips25336771Beta Tester

Hi Ray

I am using dmx pure upload with the smart image processor, the only reason for this is due to the automatic resizing feature and i could not wait for dfp to come out, this is the code used by the uploader

<?php require_once("../Connections/beads2.php"); ?>
<?php require_once("../WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("../WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>
<?php require_once( "../WA_Globals/WA_Globals.php" ); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once( "../WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if (!WA_Auth_RulePasses("Administrator")){
WA_Auth_RestrictAccess("users_LogIn.php");
}
?>
<?php require_once('../ScriptLibrary/incPureUpload.php'); ?>
<?php require_once('../ScriptLibrary/incResize.php'); ?>
<?php
// Pure PHP Upload 2.1.7
$ppu = new pureFileUpload();
$ppu->path = "../images/thumbs";
$ppu->extensions = "GIF,JPG,JPEG,BMP,PNG";
$ppu->formName = "WADAInsertForm";
$ppu->storeType = "file";
$ppu->sizeLimit = "";
$ppu->nameConflict = "uniq";
$ppu->requireUpload = "true";
$ppu->minWidth = "";
$ppu->minHeight = "";
$ppu->maxWidth = "";
$ppu->maxHeight = "";
$ppu->saveWidth = "";
$ppu->saveHeight = "";
$ppu->timeout = "600";
$ppu->progressBar = "";
$ppu->progressWidth = "";
$ppu->progressHeight = "";
$ppu->redirectURL = "";
$ppu->checkVersion("2.1.7");
$ppu->doUpload();

// Smart Image Processor 1.0.7
if (isset($HTTP_GET_VARS['GP_upload'])) {
$sip = new resizeUploadedFiles($ppu);
$sip->component = "GD2";
$sip->resizeImages = "true";
$sip->aspectImages = "true";
$sip->maxWidth = "200";
$sip->maxHeight = "200";
$sip->quality = "80";
$sip->makeThumb = "false";
$sip->pathThumb = "";
$sip->aspectThumb = "true";
$sip->naming = "suffix";
$sip->suffix = "_small";
$sip->maxWidthThumb = "";
$sip->maxHeightThumb = "";
$sip->qualityThumb = "70";
$sip->checkVersion("1.0.7");
$sip->doResize();

$resizeGoTo = "items_results.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$resizeGoTo .= (strpos($resizeGoTo, '?')) ? "&" : "?";
$resizeGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $resizeGoTo));
}

if (isset($editFormAction)) {
if (isset($_SERVER['QUERY_STRING'])) {
if (!eregi("GP_upload=true", $_SERVER['QUERY_STRING'])) {
$editFormAction .= "&GP_upload=true";
}
} else {
$editFormAction .= "?GP_upload=true";
}
}

// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $beads2;
$WA_table = "items";
$WA_sessionName = "WADA_Insert_items";
$WA_redirectURL = "items_Detail.php";
$WA_keepQueryString = false;
$WA_indexField = "ItemID";
$WA_fieldNamesStr = "ItemCatID|ItemName|ItemShortDesc|ItemLongDesc|ItemPrice|ItemThumb|ItemImage|ItemAv";
$WA_fieldValuesStr = "".((isset($_POST["ItemCatID"]))?$_POST["ItemCatID"]:"") ."" . "|" . "".((isset($_POST["ItemName"]))?$_POST["ItemName"]:"") ."" . "|" . "".((isset($_POST["ItemShortDesc"]))?$_POST["ItemShortDesc"]:"") ."" . "|" . "".((isset($_POST["ItemLongDesc"]))?$_POST["ItemLongDesc"]:"") ."" . "|" . "".((isset($_POST["ItemPrice"]))?$_POST["ItemPrice"]:"") ."" . "|" . "".((isset($_POST["ItemThumb"]))?$_POST["ItemThumb"]:"") ."" . "|" . "".((isset($_POST["ItemImage"]))?$_POST["ItemImage"]:"") ."" . "|" . "".((isset($_POST["ItemAv"]))?$_POST["ItemAv"]:"") ."";
$WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|none,none,NULL|',none,''|',none,''|none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_beads2;
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);
}
}
?>
<link href="../WA_DataAssist/styles/Ultramodern_Poppy.css" rel="stylesheet" type="text/css" />
<link href="../WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
<script language='JavaScript' src='ScriptLibrary/incPureUpload.js' type="text/javascript"></script>
<!-- InstanceEndEditable -->
</head>

<body>

<div id="outerWrapper">
<div id="contentWrapper">
<div id="rightColumn1"><!-- InstanceBeginEditable name="Menu" --> <ul class="level-0" id="cssmw">
<li><a href="index.php">home</a></li>
<li><a href="content_Results.php">content</a></li>
<li><a href="itemcategory_Results.php">category</a></li>
<li><a href="items_Results.php">products</a></li>
<li><a href="orderdetails_Results.php">orderdetails</a></li>
<li><a href="orders_Results.php">orders</a></li>
<li><a href="users_Results.php">users</a></li>
<li><a href="weekly.php">weekly</a></li>
</ul>
<script type="text/javascript">if(window.attachEvent) { window.attachEvent("onload", function() { cssmw.intializeMenu('cssmw'); }); } else if(window.addEventListener) { window.addEventListener("load", function() { cssmw.intializeMenu('cssmw'); }, true); }</script><!-- InstanceEndEditable --></div>
<div id="content"><!-- InstanceBeginEditable name="content" -->

<div class="WADAInsertContainer">
<form action="<?php echo $GP_uploadAction; ?>" method="post" enctype="multipart/form-data" name="WADAInsertForm" id="WADAInsertForm" onsubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','');return document.MM_returnValue">
<div class="WADAHeader">Insert Record</div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">Item Cat ID:</th>
<td class="WADADataTableCell"><?php
mysql_select_db($database_Connbsm);
$r=mysql_query("SELECT * FROM itemcategory;");
?>
<select name="ItemCatID" id="ItemCatID">
<?php
while ($rs=mysql_fetch_array($r)){
?>
<option value="<?php echo $rs['ItemCatID']; ?>"><?php echo $rs['ItemCatName']; ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Name:</th>
<td class="WADADataTableCell"><input type="text" name="ItemName" id="ItemName" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Short Desc:</th>
<td class="WADADataTableCell"><input type="text" name="ItemShortDesc" id="ItemShortDesc" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">ItemLongDesc:</th>
<td class="WADADataTableCell"><input type="text" name="ItemLongDesc" id="ItemLongDesc" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Price:</th>
<td class="WADADataTableCell"><input type="text" name="ItemPrice" id="ItemPrice" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">ItemThumb:</th>
<td class="WADADataTableCell"><label>
<input name="thumb" type="file" id="thumb" onchange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','','')" />
</label></td>
</tr>
<tr>
<th class="WADADataTableHeader">ItemImage:</th>
<td class="WADADataTableCell"><input type="text" name="ItemImage" id="ItemImage" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">ItemAv:</th>
<td class="WADADataTableCell"><input type="text" name="ItemAv" id="ItemAv" value="" size="32" /></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="Insert" id="Insert" value="Insert" alt="Insert" src="../WA_DataAssist/images/Poppy/Ultramodern_insert.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/Ultramodern_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADAInsertRecordID" type="hidden" id="WADAInsertRecordID" value="" />

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