Jump to content

[SOLVED] It will not record image name to db


ccrevcypsys

Recommended Posts

so far i have figured everything else out about the gd.inc.php and the image upload. the last bug/problem i have is it will not update the database on the imageName. Here is the code:

<?php
$record["image"] = $db->mySQLSafe($_POST['imageName']);

$date_str=date('Ymdhis');
$uploadFileName = str_replace(array(" ","%20"),"_",$_FILES['imageName']['name']);

if($_FILES['imageName']['size'] > $config['maxImageUploadSize']) { 

echo sprintf($lang['admin']['filemanager']['file_too_big'],$uploadFileName,format_size($config['maxImageUploadSize'])); 
unlink($_FILES['imageName']['tmp_name']);

} elseif (file_exists($GLOBALS['rootDir']."/images/uploads/".$date_str."_".$uploadFileName)) {

echo sprintf($lang['admin']['filemanager']['img_already_exists'],$uploadFileName);

} elseif (!is_uploaded_file($_FILES['imageName']['tmp_name'])) { 

echo $lang['admin']['filemanager']['upload_too_large'];

} elseif ($_FILES['imageName']['type'] != "image/jpeg" AND $_FILES['imageName']['type'] != "image/png"  AND $_FILES['imageName']['type'] != "image/x-png" AND $_FILES['imageName']['type'] != "image/pjpeg" AND $_FILES['imageName']['type'] != "image/x-jpeg" AND $_FILES['imageName']['type'] != "image/gif"){

echo sprintf($lang['admin']['filemanager']['not_valid_mime'],$uploadFileName);
unlink($_FILES['imageName']['tmp_name']); 

} else {

if (is_uploaded_file($_FILES['imageName']['tmp_name'])) {
	$savefile = $GLOBALS['rootDir']."/images/uploads/".$date_str."_".$uploadFileName;

if (move_uploaded_file($_FILES['imageName']['tmp_name'], $savefile)) {
	@chmod($savefile, 0644);
	// if image is a JPG check thumbnail doesn't exist and if not make one
$imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$uploadFileName));

if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){


	// check image is not too big
	$size = getimagesize($savefile);

	if(($size[0] > $config['gdmaxImgSize']) OR ($size[1] > $config['gdmaxImgSize'])){

	@chmod($savefile, 0775);

	$thumb=new thumbnail($savefile);
	$thumb->size_auto($config['gdmaxImgSize']);
	$thumb->jpeg_quality($config['gdquality']);
	$thumb->save($savefile);

	}


	if(file_exists($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName)){
		@chmod($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName, 0775);
		unlink($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName);
	}

	$thumb=new thumbnail($GLOBALS['rootDir']."/images/uploads/".$date_str."_".$uploadFileName);
	// see if we need to resize 
	if(($size[0] > $config['gdthumbSize']) OR ($size[1] > $config['gdthumbSize'])){
		$thumb->size_auto($config['gdthumbSize']);
	} else {
		$thumb->size_auto($size[0]);
	}
	$thumb->jpeg_quality($config['gdquality']);
	$thumb->save($GLOBALS['rootDir']."/images/uploads/thumbs/thumb_".$date_str."_".$uploadFileName);
}


	echo sprintf($lang['admin']['filemanager']['image_upload_success'],$uploadFileName);
		 // end if not set redir

	}
}


} 
	$insert = $db->insert($glob['dbprefix']."CubeCart_inventory", $record);

?>
<table>
<tr>
<td class="tdText" align="left" valign="top" width="25%">
<strong>
Image:
</strong>
  <br>
<!--(Optional and thumbnails will automatically be made IF the format chosen is compatible.)-->
</td>
<td valign="top">
<div id="selectedImage">
</div>
<div id="imageControls">
<table border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
    <td>
<input name="imageName" style="width: 200px;" class="submit" type="file" id="image" />    </td>
</tr>
</tbody>
</table>
</div>

</td>
</tr>
</table>

it doesnt give me any errors it says that it has uploaded fine but it doesnt write it to the db. somone help i need to get this done

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.