I'm very new with laravel and i am working on a project to manage images. I can handle the input when im uploading the files by drag and drop, everything right. Now i have a smartphone app, where i can send the images to the server. I can send the images to my server, and save them.
I have 2 scripts for this:
- login.php -> checks user data
- upload.php -> handels images
The app requires an url to the file : http:\ip\myproject\server\php\upload.php
Now im trying to integrate this 2 files in my laravel project, so i created a new folder under app with the files: App\server\php\files
In my Controller class is a method which takes the info from the images and write them into the database. I use this method when i upload the images on the web-page.
My Problem: When i try to call the method in my php file, i get an error in my apache2 error.log where he says that i can not find the controller class. I tried to include the class, but still getting an error. I don't know what is my error and i hope u guys can give a tip for the solution.
This is my controller method:
public function autoupload($filepath){
$file = $filepath;
$filename = basename($file);
if (!file_exists('study/images')) {
mkdir('study/images', 0777, true);
}
$file->move('study/images', $file);
if (!file_exists('study/images/thumbs')) {
mkdir('study/images/thumbs', 0777, true);
}
$thumb = Image::make('study/images/' . $filename)->resize(240, 160)->save('study/images/thumbs/' . $filename, 60);
/*Split Filename into Tokens
A_123_22-10-2016_12-05_R.jpg
* Array =
* 0 = Studienkrzl
* 1 = ProbandenNummer
* 2 = Datum
* 3 = Uhrzeit
* 4 = Kat.
*/
//22-10-2016 12-05 Datetime Format
$filename_tokens = explode('_', $filename);
$temp = $filename_tokens[2].' '.$filename_tokens[3];
$dateTime = \Datetime::createfromformat('d-m-Y H-i',$temp);
$study_krzl = substr($filename, 0, 2);
//save image details in database
$study = Study::where('study_short','=',$study_krzl)->get();
$image = $study->images()->create([
'study_id' => $study->study_id,
'file_name' => $file,
'date' => $dateTime,
'file_size' => $file->getClientSize(),
'file_path' => 'study/images/' . $filename,
'patient' => $filename_tokens[1],
'category' => basename($filename_tokens[4], ".jpg"),
'study_short' => $study_krzl,
]);
}
This is my upload.php
Why i cant call the method in the end of the file ??
Aucun commentaire:
Enregistrer un commentaire