0

コードを挿入:

 <input type="hidden" name="size" value="350000">
<input type="file" name="photo">

表示コード:

 echo "<img src='/images/" . $row['photo']. "' height='150px'><br>";

しかし、これは1枚の写真しか扱いません。複数の画像を行う方法はありますか?

フォームに入力されたデータを処理する php は次のとおりです。

 <?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
 $photo=($_FILES['photo']['name']);

 // Connects to your Database
 mysql_connect("localhost", "", "") or die(mysql_error()) ;
 mysql_select_db("dirtypol_election2016compariso") or die(mysql_error()) ;

 // Writes the information to the database
 mysql_query("INSERT INTO databasename (photo) VALUES ('$photo')") ;

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

1 に答える 1