syntax error, unexpected 'public' (T_PUBLIC)
Ich erhalte eine Fehlermeldung, die Schreien an mir, dass anscheinend ein syntax-Fehler?
Ich bin wirklich nicht sicher, wohin ich gehe falsch gemacht?
public function upload() {
//getting all of the post data
$file = array('image' => Input::file('image'));
//setting up rules
$rules = array('image' => 'required',); //mimes:jpeg,bmp,png and for max size max:10000
//doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
//send back to the page with the input data and errors
return Redirect::to('upload')->withInput()->withErrors($validator);
}
else {
//checking file is valid.
if (Input::file('image')->isValid()) {
$destinationPath = 'uploads'; //upload path
$extension = Input::file('image')->getClientOriginalExtension(); //getting image extension
$fileName = rand(11111,99999).'.'.$extension; //renameing image
Input::file('image')->move($destinationPath, $fileName); //uploading file to given path
//sending back with message
Session::flash('success', 'Upload successfully');
return Redirect::to('upload');
}
else {
//sending back with error message.
Session::flash('error', 'uploaded file is not valid');
return Redirect::to('upload');
}
}
}
- die Linie Ursache-problem ?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Benötigen Sie eine Kontext-Klasse zur Verwendung von access-IDS.
Ihr code sollte sein:
Wenn Sie nicht innerhalb einer Klasse, benutzen Sie einfach
function upload()
, nichtpublic function upload()
.Wenn Sie innerhalb einer Klasse, der Fehler liegt, bevor Sie den code, den Sie angegeben haben.