Howdy Everyone! We are beginners at this, and have finally got our picture uploader to work. Now we just need to adjust it slightly so the picture is downsized to fit into our inventory page. Please though, no references back to the manual or instructions we canβt understand. π
The Add Record section is divided into two sections, the form page and the executable page. I have included the script for both of them below. Please let us know where we would add the additional script, what it would consist of, and any errors we might encounter in doing so. The picture should be approximately 350 X 230.
Thanks a million for your help!
FIRST SCRIPT
<form enctype="multipart/form-data" method="post" action="<?php echo
$PHP_SELF ?>">
Picture<br>
<input type="file" name="pic">
<br><br>
<input type="text" name="filename">
<input type="submit" name="submit" value="Upload">
</form>
<?php
if ($submit) {
$connection = mysql_connect("**", "", "***")
or die ("Couldn't connect to server.");
$db = mysql_select_db("alexander", $connection)
or die ("Couldn't select database.");
copy($pic, "/httpd/realapplications/pics/$filename");
mysql_query("INSERT INTO pics (filename) VALUES ('$filename')") or die
(mysql_error());
echo "temp file: $pic<br>\n";
echo "file name: $filename<br>\n";
echo "file size: $filesize<br>\n";
echo "file type: $filetype<br>\n";
echo "<br>\n";
echo "<img src=images/$filename><br>\n";
}
?>
</center>
</body>
SECOND SCRIPT
<?
if ($submit) {
$connection = mysql_connect("**", "", "***")
or die ("Couldn't connect to server.");
$db = mysql_select_db("alexander", $connection)
or die ("Couldn't select database.");
copy($pic, "/httpd/realapplications/html/pics/$filename");
$filesize=filesize($pic);
$filetype=filetype($pic);
mysql_query("INSERT INTO boom_lifts VALUES
('$size', '$year', '$manufacturer', '$description', '$price', ' ',
'$model', '$filename', '$filesize', '$filetype')") or die (mysql_error());
echo "<table cellspacing=5 cellpadding=5>";
echo "<tr><td valign=top><strong>Size:</strong></td><td
valign=top>$size</td></tr>";
echo "<tr><td valign=top><strong>Year:</strong></td><td
valign=top>$year</td></tr>";
echo "<tr><td valign=top><strong>Manufacturer:</strong></td><td
valign=top>$manufacturer</td></tr>";
echo "<tr><td valign=top><strong>Model:</strong></td><td
valign=top>$model</td></tr>";
echo "<tr><td valign=top><strong>Item Description:</strong></td><td
align=top>$description</td></tr>";
echo "<tr><td valign=top><strong>Price:</strong></td><td valign=top>\$
$price</td></tr>";
echo "<tr><td valign=top><strong>File Name:</strong></td><td
valign=top>$filename</td></tr>";
echo "<tr><td valign=top><strong>Picture:</strong></td><td valign=top><img
src=../../pics/$filename></td></tr>";
echo "</table>";
}
?>
<a href=\"index.html\">Return to Menu</a>
</body>