thumbnail file field doesn't upload or add path to DB
Posted: Fri Mar 21, 2003 8:59 pm
My thumbnail field in my form won't work, it doesn't upload a file, give me an error, or put the path of the file into the database. It's as if I haven't even set that field in the form or something.
I'm almost 100% sure my filenames are correct and field names are correct. I know for sure the code is right because its an exact replica of a field called picture, and the picture field works wonderfully, it sends the path to the mysql database, and uploads the file to the directory necessary.
Here's the code
If you need to see the code for the form I can post that too.
The thumbnail field is called simply thumbnail while the picture field is called picture. If you can help and/or figure this out I'd greatly appreciate it. Then again I'm sure it's just some simple mistake that I'm not seeing.
I'm almost 100% sure my filenames are correct and field names are correct. I know for sure the code is right because its an exact replica of a field called picture, and the picture field works wonderfully, it sends the path to the mysql database, and uploads the file to the directory necessary.
Here's the code
Code: Select all
<?php
if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
copy($HTTP_POST_FILES['picture']['tmp_name'], "../images/".$HTTP_POST_FILES['picture']['name']) or die("tis broken");
$imagepath = "http://www.pancorp.com/images/".$HTTP_POST_FILES['picture']['name']."";
if (isset($HTTP_POST_VARS['thumbnail'])) {
copy($HTTP_POST_FILES['thumbnail']['tmp_name'], "../images/s/".$HTTP_POST_FILES['thumbnail']['name']) or die("could not copy2");
$thumbpath = "http://www.pancorp.com/images/s/".$HTTP_POST_FILES['thumbnail']['name']."";
}
$insertSQL = sprintf("INSERT INTO products (id, type, category, picture, thumbnail, partA, nameA, priceA, partB, nameB, priceB, partC, nameC, priceC, partD, nameD, priceD, partE, nameE, priceE, partF, nameF, priceF, info, featured) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['id'], "int"),
GetSQLValueString($HTTP_POST_VARS['type'], "text"),
GetSQLValueString($HTTP_POST_VARS['category'], "text"),
GetSQLValueString($imagepath, "text"),
GetSQLValueString($thumbpath, "text"),
GetSQLValueString($HTTP_POST_VARS['partA'], "text"),
GetSQLValueString($HTTP_POST_VARS['nameA'], "text"),
GetSQLValueString($HTTP_POST_VARS['priceA'], "text"),
GetSQLValueString($HTTP_POST_VARS['partB'], "text"),
GetSQLValueString($HTTP_POST_VARS['nameB'], "text"),
GetSQLValueString($HTTP_POST_VARS['priceB'], "text"),
GetSQLValueString($HTTP_POST_VARS['partC'], "text"),
GetSQLValueString($HTTP_POST_VARS['nameC'], "text"),
GetSQLValueString($HTTP_POST_VARS['priceC'], "text"),
GetSQLValueString($HTTP_POST_VARS['partD'], "text"),
GetSQLValueString($HTTP_POST_VARS['nameD'], "text"),
GetSQLValueString($HTTP_POST_VARS['priceD'], "text"),
GetSQLValueString($HTTP_POST_VARS['partE'], "text"),
GetSQLValueString($HTTP_POST_VARS['nameE'], "text"),
GetSQLValueString($HTTP_POST_VARS['priceE'], "text"),
GetSQLValueString($HTTP_POST_VARS['partF'], "text"),
GetSQLValueString($HTTP_POST_VARS['nameF'], "text"),
GetSQLValueString($HTTP_POST_VARS['priceF'], "text"),
GetSQLValueString($HTTP_POST_VARS['info'], "text"),
GetSQLValueString(isset($HTTP_POST_VARS['featured']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_userLogin, $userLogin);
$Result1 = mysql_query($insertSQL, $userLogin) or die(mysql_error());
$insertGoTo = "http://www.pancorp.com/siteadmin/admin.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>If you need to see the code for the form I can post that too.
The thumbnail field is called simply thumbnail while the picture field is called picture. If you can help and/or figure this out I'd greatly appreciate it. Then again I'm sure it's just some simple mistake that I'm not seeing.