Created
April 26, 2019 16:29
-
-
Save jhoanborges/5b16507595aa9ba2bb64419c7769dcff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function logo(Request $request){ | |
//http://plugins.krajee.com/file-input#ajax-uploads | |
try{ | |
$id = 1; | |
$file=$_FILES['fileBlob']; | |
//se valida que el usuario sea de status 1 = aprobado y que no sea status 2=ya se recibieron datos | |
// your file | |
// organizar | |
$file = $_FILES['fileBlob']['name']; | |
$info = pathinfo($file); | |
$extension = $info['extension']; | |
$validator = Validator::make($request->all(), [ | |
//archivos | |
'file' => 'sometimes|max:10048|mimes:jpg,jpeg,bmp,png,gif,svg,pdf', | |
]); | |
if ($validator->fails()) { | |
return response()->json($validator->errors(), 500); | |
} | |
//for file | |
$uniqueid=uniqid(); | |
$name=$uniqueid.'.'.$extension; | |
\Storage::disk('img')->put($name, file_get_contents($_FILES['fileBlob']['tmp_name'] )); | |
//$landing = Precalificador::create($request->all()); | |
$cliente = Settings::where('id', $id)->update([ | |
'avatar'=>$name, | |
]); | |
//documetnacion | |
//http://plugins.krajee.com/file-input#ajax-uploads | |
$file = $_FILES['fileBlob']['tmp_name']; // the path for the uploaded file chunk | |
$fileName = $_POST['fileName']; // you receive the file name as a separate post data | |
$fileSize = $_POST['fileSize']; // you receive the file size as a separate post data | |
$fileId = $_POST['fileId']; // you receive the file identifier as a separate post data | |
$index = $_POST['chunkIndex']; // the current file chunk index | |
$totalChunks = $_POST['chunkCount']; // the total number of chunks for this file | |
//$targetFile = $targetDir.'/'.$fileName; // your target file path | |
return response()->json( | |
[ | |
'chunkIndex' => $index, // the chunk index processed | |
'initialPreview' => url('img/'.$name), // the thumbnail preview data (e.g. image) | |
'initialPreviewConfig' => [ | |
[ | |
'type' => 'image', // check previewTypes (set it to 'other' if you want no content preview) | |
'caption' => $fileName, // caption | |
'key' => $fileId, // keys for deleting/reorganizing preview | |
'fileId' => $fileId, // file identifier | |
'size' => $fileSize, // file size | |
'zoomData' => $name, // separate larger zoom data | |
] | |
], | |
'append' => true | |
] | |
); | |
}catch(\Exception $e){ | |
return response()->json( | |
[ | |
'error' => 'El archivo no ha podido ser subido' | |
] | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment