Hi everyone
I have been working on this code for 2 days now and while progressing have encountered this error:
Warning: imagejpeg() [function.imagejpeg]: Unable to open 'C:/web/root/images/thumbs/' for writing in C:\web\root\devfiles\additemresize.php on line 40
here is code for the file outputting the error i have noted line 40 so you can spot it easily:
Also the value of $GLOBALS['thumbpath'] is : 'C:/web/root/images/thumbs/'
if anyone can see why this error is occuring please let me know 🙂
include ('c:/web/db_connect.php');
if(isset($_POST['enter'])) {
$name = $_POST['name'];
$description = $_POST['description'];
//$image = $_POST['image'];
$catagory = $_POST['catagory'];
$guest_price = $_POST['guest_price'];
$member_price = $_POST['member_price'];
$datetime = date('Y-m-d');
$stock_level = $_POST['stock_level'];
$size = $_POST['size'];
if ( $_FILES['image'] ['name'] != "")
{
$uploadedFile = $_FILES['image']['tmp_name'];
$newFile = $GLOBALS['imagepath'].$_FILES['image']['name'];
move_uploaded_file($uploadedFile, $newFile);
$tempimg = imagecreatefromjpeg($newFile); // Make A New Temporary Image To Create The Thumbanil From
$currwidth = imagesx($tempimg); // Current Image Width
$currheight = imagesy($tempimg); // Current Image Height
if ($currheight > $currwidth) { // If Height Is Greater Than Width
$zoom = $GLOBALS['thumbw'] / $currheight; // Length Ratio For Width
$newheight = $GLOBALS['thumbh']; // Height Is Equal To Max Height
$newwidth = $currwidth * $zoom; // Creates The New Width
} else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height)
$zoom = $GLOBALS['thumbw'] / $currwidth; // Length Ratio For Height
$newwidth = $GLOBALS['thumbw']; // Width Is Equal To Max Width
$newheight = $currheight * $zoom; // Creates The New Height
}
$Thumb = imagecreatetruecolor($newwidth, $newheight); // Make New Image For Thumbnail
imagecopyresampled($Thumb, $tempimg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It)
/*line 40*/ imagejpeg($Thumb, $GLOBALS['thumbpath'] , $_FILES['image']['name']); // Saving The Image
imagedestroy($tempimg); // Destroying The Temporary Image
imagedestroy($Thumb); // Destroying The Other Temporary Image
}
else {("No image selected the defaut will be applied for this product");}
$query = "INSERT INTO stock (name, description,imagepath, thumbpath, catagory, guest_price, member_price, datetime, stock_level, size)
VALUES ('$name', '$description', '$newFile', ' ', '$catagory', '$guest_price', '$member_price', '$datetime', '$stock_level', '$size')";
$result = mysql_query($query); //image is inserted below if one has been selected
mysql_close();
}
?>
<tr>
<td width="780" colspan="4" border="1" align="Left" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<h2> Add New Product Details </h2>
<form method="post" action="additemresize.php" enctype="multipart/form-data">
<p><b>Item Name :
<input type="Text" name="name">
<br>
Item Description :
<input type="text" name="description">
<br>
Item Image :
<input type="file" name="image">
<br>
Item Catagory :
<input type="Text" name="catagory">
<br>
Non Member Price :
<input type="Text" name="guest_price">
<br>
Member Price :
<input type="Text" name="member_price">
<br>
Stock Level :
<input type="Text" name="stock_level">
<br>
Size :
<input type="Text" name="size">
<br>
<b></p>
<input type= "submit" name="enter" value="Confirm and Add">
</form>
<?php
if(isset($_POST['enter'])) {
if ($result) {echo ("The item $name has been added to the shop and will automaticly appear in the shop when in stock");}}
?>
</td>
</tr>
<?php require ($_SERVER['DOCUMENT_ROOT']. '/includes/footer.php'); ?>