<?php session_start(); ?>
<html>
<form action="upload.php" method ="post">
<table>
<tr><td><input type = "hidden" name="MAX_FILE_SIZE" value = "102400" /></td></tr>
<tr><td>Filename:</td><td><input type = "text" name="filename" value = "" /></td></tr>
<tr><td>Select File: </td><td><input type = "file" name = "fupload" /></td></tr>
<tr><td>Text:</td><td><input type = "text" name="txt" value = "" /></td></tr>
<tr><td><input type = "submit" value = "Upload!"></td></tr>
</table>
<?php
if (isset ($_FILES['fupload'])){
$filename = $_FILES['fupload']['name'];
$newfilename = $_POST[filename];
$newfilename = strtolower($newfilename);
$txt= $_POST[txt];
//printing file information
print "<table>";
print "<tr><td>Original Name:</td><td> ". $_FILES['fupload']['name']."</td></tr>";
print "<tr><td>New Name:</td><td> ".$newfilename."</td></tr>";
print "<tr><td>Size: </td><td>". $_FILES['fupload']['size']."</td></tr>";
print "<tr><td>Type: </td><td>". $_FILES['fupload']['type']. "</td></tr>";
print "<tr><td>Error: </td><td>". $_FILES['fupload']['error']. "</td></tr>";
print "</table>";
//checking the type of file, if it is image it will display it
if ($_FILES['fupload']['type'] == "image/jpeg"){
$source = $_FILES['fupload']['tmp_name'];
$target = "products/images/".$newfilename. ".jpg";
move_uploaded_file($source, $target); // or die ("Couldnt copy");
//displaying the image
$imagesize = getImageSize($target);
$imgstr = "<p><img width=\"$size[0]\" height=\"$size[1]\" ";
$imgstr .= "src=\"$target\" alt=\"uploaded image\" ></p>";
$imagepath = $yoursite.$target;
print $imgstr;
print "The link to your image is: ".$yoursite.$target;//link to the image
print $texthere;
}
}
//-------------------------------------------------------------------------------------
?>
</html>