2016-09-21 1 views
0
<form name="property" action="" method="post" enctype="multipart/form-data"> 
Select Image 
<input type="file" name="upload[]" multiple="multiple" id="image"/> 
<input type="submit" value="Submit" name="submit" style="width:200px; height:30px;" /> 
</form> 

MY Php Code:Problem beim Hochladen mehrerer Bilder? db Bild angehängt

if(isset($_POST['submit'])) 
{ 
$total = count($_FILES['upload']['name']); 
for($i=0; $i<$total; $i++) 
{ 
$tmpFilePath = $_FILES['upload']['tmp_name'][$i]; 
if ($tmpFilePath != "") 
{ 
$newFilePath[] = "upload/" . $_FILES['upload']['name'][$i]; 
$values_insert = implode(',', $newFilePath); 
if(move_uploaded_file($tmpFilePath, $newFilePath)) 
{ 
$date=date("Y-m-d"); 
} 
} 
} 
$d=mysql_query("INSERT INTO properties (iname,cdate) VALUES('".$values_insert."',NOW())") or die(mysql_error()); 
} 

Here It shows the upload foldername and image name, I want only image name sperated by comma, please see the image

Hinweis:
In Datenbank den Pfad Upload-Verzeichnis Ordner und Bild Bild wird auf die Datenbank gehen, ich will nur Name Bild getrennt durch Komma. Zum Beispiel ist die erwartete Ausgabe Chrysanthemum.jpg, Desert.jpg. Ich weiß nicht, was das Problem ist. Bitte führe mich. Schau dir meine Code- und Bildanhangsdetails an.

Antwort

0

Thing this tun tun fyi - Einrückung Code würde Menschen helfen zu lesen und Ihnen helfen.

if(isset($_POST['submit'])) 
    { 
    $total = count($_FILES['upload']['name']); 
    for($i=0; $i<$total; $i++) 
    { 
    $tmpFilePath = $_FILES['upload']['tmp_name'][$i]; 
    if ($tmpFilePath != "") 
    { 
    $newFilePath = "upload/" . $_FILES['upload']['name'][$i]; 
    $newFilePath2[] = $_FILES['upload']['name'][$i]; 
    $values_insert = implode(',', $newFilePath2); 
    if(move_uploaded_file($tmpFilePath, $newFilePath)) 
    { 
    $date=date("Y-m-d"); 
    } 
    } 
    } 
    $d=mysql_query("INSERT INTO properties (iname,cdate) VALUES('".$values_insert."',NOW())") or die(mysql_error()); 
    } 
Verwandte Themen