JamesGMills
Programmer
Hi, Happy Christmas... this is what i have so far:
<?
if(!empty($_FILES)) {
require_once("includes/dbc.inc.php");
$filename = $_FILES['file']['name']; // Get the client side file name
$tempFilename = $_FILES['file']['tmp_name']; // Temporary file name server side
$fileSize = $_FILES['file']['size']; // size of uploaded file
$fileType = $_FILES['file']['type']; // File type
$fileNameParts = explode(".", $filename); // Get file extension
$fileExtension = $fileNameParts[1]; // Part behind last dot
$filenameNoExt = $fileNameParts[0]; // File name with no extension
$tempFileOpen = fopen($tempFilename, "r"); // Read file
$binaryImage = fread($tempFileOpen, fileSize($tempFilename)); // Create binary image for blob in db
$binaryImage = addslashes($binaryImage);
// Create thumbnail
$originalWidth = imagesx($tempFilename); // get original source image width
$originalHeight = imagesy($tempFilename); // and height
$dateAdded = date("Y-m-d G:i:s"); // Time record added
// Add to database
$dbConnect = db_connect("****");
$query = "INSERT INTO Images (ID, Title, Image, Thumbnail, DateAdded, FileType, FileSize, FileName) VALUES ('', '$filenameNoExt','$binaryImage' ,'' , '$dateAdded', '$fileType', '$fileSize', '$filename')";
$result = mysql_query($query, $dbConnect) or die(mysql_error());
}
?>
I would like to resize the image before I save it to the database. I will then use this same idea to create a thumbnail.
The problem that I am finding is that most of the script examples I have found so far all resize images from a folder not directly from a form and so i am slightly stuck right now.
Cheers for any advice, guidance.
James
------------------------
<?
if(!empty($_FILES)) {
require_once("includes/dbc.inc.php");
$filename = $_FILES['file']['name']; // Get the client side file name
$tempFilename = $_FILES['file']['tmp_name']; // Temporary file name server side
$fileSize = $_FILES['file']['size']; // size of uploaded file
$fileType = $_FILES['file']['type']; // File type
$fileNameParts = explode(".", $filename); // Get file extension
$fileExtension = $fileNameParts[1]; // Part behind last dot
$filenameNoExt = $fileNameParts[0]; // File name with no extension
$tempFileOpen = fopen($tempFilename, "r"); // Read file
$binaryImage = fread($tempFileOpen, fileSize($tempFilename)); // Create binary image for blob in db
$binaryImage = addslashes($binaryImage);
// Create thumbnail
$originalWidth = imagesx($tempFilename); // get original source image width
$originalHeight = imagesy($tempFilename); // and height
$dateAdded = date("Y-m-d G:i:s"); // Time record added
// Add to database
$dbConnect = db_connect("****");
$query = "INSERT INTO Images (ID, Title, Image, Thumbnail, DateAdded, FileType, FileSize, FileName) VALUES ('', '$filenameNoExt','$binaryImage' ,'' , '$dateAdded', '$fileType', '$fileSize', '$filename')";
$result = mysql_query($query, $dbConnect) or die(mysql_error());
}
?>
I would like to resize the image before I save it to the database. I will then use this same idea to create a thumbnail.
The problem that I am finding is that most of the script examples I have found so far all resize images from a folder not directly from a form and so i am slightly stuck right now.
Cheers for any advice, guidance.
James
------------------------