2016-11-24 2 views
0

Ich habe eine Bilddatei auf einem Server laden mit slim 3. Ich den Dateipfad in der Tabelle und die jeweiligen Bild in Ordner auf dem ServerWie lade ich eine Bilddatei in Slim 3 hoch?

$filenamePath = md5(time().uniqid()).".jpg"; 
     $decoded=base64_decode($image); 
     file_put_contents("images/".$filenamePath,$decoded); 

     $sth = $this->db->prepare("UPDATE orders set status =:status, 
             total_amount=:amount,created_at=:date1,receipt=:path WHERE id=:orderId"); 
     $sth->bindParam("orderId",$orderid); 
     $sth->bindParam("status", $status); 
     $sth->bindParam("amount", $amount); 
     $sth->bindParam("date1", $date); 
     $sth->bindParam("path", $filenamePath); 
     $sth->execute(); 

Dies ist mein Code in slim 3 speichern mag Klasse this is my directory stucture of folder on server Was ist los? Kann jemand helfen?

+0

Erhalten Sie irgendwelche Fehler? –

+1

'Ich muss Image-Datei auf dem Server mit Slim 3' hochladen. Nun, was läuft schief? Und was hat das mit Android zu tun? – greenapps

+0

schlug fehl, Stream zu öffnen keine solche Datei oder Verzeichnis .. Dieser Fehler ist –

Antwort

1
$filenamePath = md5(time().uniqid()).".jpg"; 
    $decoded=base64_decode($image); 
    file_put_contents("../images/".$filenamePath,$decoded); 

    $sth = $this->db->prepare("UPDATE orders set status =:status, 
            total_amount=:amount,created_at=:date1,receipt=:path WHERE id=:orderId"); 
    $sth->bindParam("orderId",$orderid); 
    $sth->bindParam("status", $status); 
    $sth->bindParam("amount", $amount); 
    $sth->bindParam("date1", $date); 
    $sth->bindParam("path", $filenamePath); 
    $sth->execute(); 

nur Pfad wie in obigem Code ändern und die Erlaubnis für Bilder Ordner

1

Versuchen vollständigen Pfad des Bildes

Beispiel:

file_put_contents("/testslim/v1/src/images/".$filenamePath,$decoded); 
Verwandte Themen