GD dosya ekleme, yeniden boyutlandırmak ve php resim upload script adlandırmak

0 Cevap php

I have this script which allows a picture to be uploaded and then a pointer is stored in a DB to the file on the file system. I got this script from another StackOverflow question and it does pretty much everything I need except for 2 things. The first thing I need is to be able to resize the images and the second part I've just read about is to rename the file to prevent user errors etc.

Burada kullanıcı giriş formu form verilerini alır ve görüntüler dir DB ve resim verileri yazar yükleme dosyasıdır.

 <?php

//This is the directory where images will be saved
$target = "your directory";
$target = $target . basename( $_FILES['photo']['name']);

//This gets all the other information from the form
$name=$_POST['nameMember'];
$bandMember=$_POST['bandMember'];
$pic=($_FILES['photo']['name']);
$about=$_POST['aboutMember'];
$bands=$_POST['otherBands'];


// Connects to your Database
mysql_connect("yourhost", "username", "password") or die(mysql_error()) ;
mysql_select_db("dbName") or die(mysql_error()) ;

//Writes the information to the database
mysql_query("INSERT INTO tableName (nameMember,bandMember,photo,aboutMember,otherBands)
VALUES ('$name', '$bandMember', '$pic', '$about', '$bands')") ;

//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.";
}
?>

0 Cevap