hi folks, i have never attempted this before but i have found a helpfull enough script which allows me to upload a file to a server and store the image path in a database. The script is not exactly what i require thou, i need to be able to take that image and resize it twice so that it is both 400 height 80 width and 40 height 8 width and then these two values get stored into the database.
Here is the code that i am currently using
<?php
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$name=$_POST['name'];
$pic=($_FILES['photo']['name']);
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("image") or die(mysql_error());
//Writes the information to the database
mysql_query("INSERT INTO `images` VALUES ('$name', '$pic')");
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES ['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>