Location: PHPKode > projects > PHP Gateway > e-comm/catalog/images2.php
 <style type="text/css">

.link
{
  color: steelblue;
  text-decoration: underline;
  cursor: pointer;
  cursor: hand;
  font-family:arial;
  font-size:14px;
}

</style>


<?
print "<center>";
print "<b><big>Product Wizard</b></big>";
print "<br><b>Full Image:</b><br>On this page, you simply upload the full picture of your product.";
?>

<?php
  $uploadDir    = "ColorVariations/";        // upload dir
  $numOfUploads = '1';         // number of files to upload
  $maxFileSize  = '500000';    // maximum file size in bytes
?>

  <?php echo '<?xml version="1.0" encoding="iso-8859-1"?>';?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html>
  <head><title>Upload Image</title></head>
  <body bgcolor="#ffffff">
  <h5>Please Choose a File and click Submit</h5>
  <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="10000000">
  <?php
  $num = '0';
  while($num < $numOfUploads)
    {
        echo '<div><input name="userfile[]" type="file"></div>';
        $num++;
        }

	print("<input type=hidden name=pricat value='".$_POST[pricat]."'>");
	print("<input type=hidden name=subcat value='".$_POST[subcat]."'>");
	print("<input type=hidden name=brand value='".$_POST[brand]."'>");
	print("<input type=hidden name=thumb value='".$_POST[full]."'>");
  ?>
  <input type="submit" value="Submit">
  </form>

</body></html>

<?php
  // check if a file has been submitted
  if(!isset($_FILES['userfile']['tmp_name']))
        {
        echo '<div>No files uploaded</div>';
        }
  else
    {
    // upload the files...
    upload($maxFileSize, $uploadDir);
    }
function upload($maxFileSize, $uploadDir){
  $i=0;
  // loop through the array
  for($i=0; $i < count($_FILES['userfile']['tmp_name']);$i++)
  // check if there is a file in the array
  if(is_uploaded_file($_FILES['userfile']['tmp_name'][$i]))
    {
    // check the file is less than the maximum file size
    if($_FILES['userfile']['size'][$i] < $maxFileSize)
        {
        // copy the file to the specified dir
        if(@copy($_FILES['userfile']['tmp_name'][$i],$uploadDir.'/'.$_FILES['userfile']['name'][$i]))
            {
            // give praise and thanks to the php god

            $trigger = w00t;
            $_POST[full] = "ColorVariations/".$_FILES['userfile']['name'][$i];
            print("<img src=".$_POST[full].">");
            echo'<div color=red>Upload of file '.$_FILES['userfile']['name'][$i].' successful.</div>';
            }
        else
            {
            // print an error message
            echo '<div>Upload of file '.$_FILES['userfile']['name'][$i].' Failed.</div>';
            }
        }
    else
        {
        // if the file is not less than the maximum allowed, print an error
        echo
        '<div>File exceeds the Maximum File limit</div>
        <div>Maximum File limit is '.$maxFileSize.'</div>
        <div>File '.$_FILES['userfile']['name'][$i].' is '.$_FILES['userfile']['size'][$i].' bytes</div>
        <hr />';
        }
    }
}

	print("<form action=thumb.php method=post>");
	foreach($_FILES['userfile']['name'] as $dim)
	{
		print("<input type=hidden name=colorvar[] value='$dim'>");
	}
	print("<input type=hidden name=pricat value='".$_POST[pricat]."'>");
	print("<input type=hidden name=subcat value='".$_POST[subcat]."'>");
	print("<input type=hidden name=brand value='".$_POST[brand]."'>");
	print("<input type=hidden name=thumb value='".$_POST[full]."'>");
	print("<input type=submit value='Continue'><br><small><b>!*</b> Note: You may want to upload an image first before continuing. <b>*!</b></small>");
	print("</form>");
?>
Return current item: PHP Gateway