Location: PHPKode > projects > Multi-lingual E-Commerce System > admin/product_image.php
<?php
$language_code='EN';
$include_path = '/home/httpd/html/gwenshop';

require_once($include_path.'/classes/Product.class')

$obj = new Product;
$obj->Product_ID = $_GET['product'];
$obj->retrieve();
list ($name,$desc) = $obj->getDescription($language_code);

if (!isset($_POST['file_path'])) {
?>
<h3>Image Upload for <? echo $name; ?></h3>
<form enctype="multipart/form-data" action="product_image.php method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="80000">
<input type="hidden" name="product" value="<? echo $_GET['product']; ?>">
<table>
<tr><td>This is a :</td><td></td></tr>
<tr><td align="right">Icon</td><td><input type="radio" name="image_type" value="icon"></td></tr>
<tr><td align="right">Full image</td><td><input type="radio" name="image_type" value="image"></td></tr>
<tr><td>Server name</td><td><input type="text" name="file_path" value="/images/..."></td></tr>
Select file: <input name="userfile" type="file">
<input type="submit" value="Upload Image">
</form>
<?php
} # end if isset file_path

else {

$uploaddir = '/tmp/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    print "<p>File is valid, and was successfully uploaded.</p>\n";
} else {
    print "<p>Invalid file upload  Here's some debugging info:</p>\n";
    print_r($_FILES);
    exit;
}
$destination = $include_path.$_POST['file_name'];
if (copy ($uploadfile,$destination)) {
    print "<p>File was successfully moved to $destination.</p>\n";
    unlink ($uploadedfile);
} else {
    print "<p>Unable to move file to $destination.</p>\n";
    exit;
}

$obj = new Product;
$obj->Product_ID = $_POST['product'];
$obj->retrieve();
if ($_POST['image_type'] == 'icon') { 
	$obj->Product_Icon = $_POST['file_path'];
}
elseif ($_POST['image_type'] == 'image') { 
	$obj->Product_Image = $_POST['file_path'];
}
$obj->store();
?>

<?php
} # end else
?>
Return current item: Multi-lingual E-Commerce System