Erstes Laravel-Projekt. Ich baue eine Funktion, mit der ich ein Bild hochladen kann. Alles, was ich habe ist, basierend auf this PDF (Seite 98-101)Laravel: Undefinierter Wert beim Hochladen von Bildern
Mein blade.php
<?php echo Form::open(array('url' =>'/product/imgedit','files'=>'true'));
echo 'Adj meg egy új képet';
echo Form::file('image');
echo Form::submit('Upload File');
echo Form::close();?>
Mein Router
Route::get('product/{id}/imgedit', '[email protected]');
Route::post('product/imgedit', '[email protected]');
Mein Controller:
public function imgreq($id)
{
$product = DB::select('select * FROM inventory WHERE barcode = ?', [$id]);;
return view('productimgupl', ['product' => $product]);
}
public function imgupl()
{
$file = $request->file('image');
//Display File Name
echo 'File Name: ' . $file->getClientOriginalName();
echo '<br>';
//Display File Extension
echo 'File Extension: ' . $file->getClientOriginalExtension();
echo '<br>';
//Display File Real Path
echo 'File Real Path: ' . $file->getRealPath();
echo '<br>';
//Display File Size
echo 'File Size: ' . $file->getSize();
echo '<br>';
//Display File Mime Type
echo 'File Mime Type: ' . $file->getMimeType();
//Move Uploaded File
$destinationPath = '/media/productimg/';
$file->move($destinationPath, $file->getClientOriginalName());
}
Fehlermeldung:
Error in InventoryController.php Linie 28: Undefined variable: Anfrage
Was ich falsch gemacht?
Vielen Dank, es hat funktioniert :) – Feralheart
Kein Problem. Froh, dass ich Helfen kann. – Mark