Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1361340928 | |||
| 1bda30e957 | |||
| a87423d879 | |||
| 24cda34681 | |||
| 2c514a8ab6 | |||
| b1ea728c15 | |||
| 9d5c20113f | |||
| 47762a8557 | |||
| 939a4fe03e | |||
| 493de65892 | |||
| 23ae8e1b1d | |||
| 7ad20993d9 |
@@ -32,7 +32,3 @@ auth.json
|
||||
# File XLSX temporanei importati
|
||||
/public/userarea/imported_trf/*.xlsx
|
||||
/public/userarea/xlstemplates/*.xlsx
|
||||
|
||||
# Ignora cartelle di foto generate
|
||||
/public/photostrf/
|
||||
/public/photostrf/qrcodes/
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Userarea;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UploadPhotosMobileController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$iddatadb = $request->query('iddatadb');
|
||||
|
||||
if (empty($iddatadb)) {
|
||||
return response('ID riga non fornito', 400);
|
||||
}
|
||||
|
||||
// Show the upload form
|
||||
return view('userarea.upload_photos_mobile', [
|
||||
'iddatadb' => $iddatadb
|
||||
]);
|
||||
}
|
||||
|
||||
public function upload(Request $request)
|
||||
{
|
||||
// Validation
|
||||
$request->validate([
|
||||
'photo' => 'required|file|mimes:jpeg,png,gif,heic,heif|max:5120', // 5MB
|
||||
'iddatadb' => 'required|integer'
|
||||
]);
|
||||
|
||||
$iddatadb = $request->input('iddatadb');
|
||||
$photo = $request->file('photo');
|
||||
$iduserlogin = auth()->id(); // assuming Laravel authentication
|
||||
|
||||
// Check if user exists
|
||||
$userExists = DB::table('auth_users')->where('id', $iduserlogin)->exists();
|
||||
if (!$userExists) {
|
||||
return response()->json(['success' => false, 'message' => 'Utente non valido']);
|
||||
}
|
||||
|
||||
// Upload folder
|
||||
$uploadDir = public_path('photostrf');
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0755, true);
|
||||
}
|
||||
if (!is_writable($uploadDir)) {
|
||||
return response()->json(['success' => false, 'message' => 'La cartella photostrf non è scrivibile']);
|
||||
}
|
||||
|
||||
// New filename
|
||||
$timestamp = now()->format('YmdHis');
|
||||
$originalName = pathinfo($photo->getClientOriginalName(), PATHINFO_FILENAME);
|
||||
$extension = strtolower($photo->getClientOriginalExtension());
|
||||
|
||||
$newFileName = "{$iddatadb}-{$timestamp}-{$originalName}.{$extension}";
|
||||
$destination = $uploadDir . '/' . $newFileName;
|
||||
|
||||
// Move uploaded file
|
||||
$photo->move($uploadDir, $newFileName);
|
||||
|
||||
// Save DB record
|
||||
DB::table('datadb_photos')->insert([
|
||||
'iddatadb' => $iddatadb,
|
||||
'file_path' => $newFileName,
|
||||
'file_name' => $newFileName,
|
||||
'uploaded_by' => $iduserlogin
|
||||
]);
|
||||
|
||||
return response()->json(['success' => true, 'message' => 'Foto caricata con successo']);
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 571 KiB |
|
After Width: | Height: | Size: 571 KiB |
|
After Width: | Height: | Size: 571 KiB |
|
After Width: | Height: | Size: 571 KiB |
|
After Width: | Height: | Size: 571 KiB |
|
After Width: | Height: | Size: 571 KiB |
|
After Width: | Height: | Size: 571 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 39 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 38 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 510 B |
|
After Width: | Height: | Size: 511 B |
|
After Width: | Height: | Size: 518 B |
|
After Width: | Height: | Size: 511 B |
|
After Width: | Height: | Size: 515 B |
|
After Width: | Height: | Size: 509 B |
|
After Width: | Height: | Size: 508 B |
|
After Width: | Height: | Size: 518 B |
|
After Width: | Height: | Size: 510 B |
|
After Width: | Height: | Size: 516 B |
|
After Width: | Height: | Size: 512 B |
|
After Width: | Height: | Size: 518 B |
|
After Width: | Height: | Size: 511 B |
|
After Width: | Height: | Size: 517 B |
|
After Width: | Height: | Size: 513 B |
|
After Width: | Height: | Size: 510 B |
|
After Width: | Height: | Size: 514 B |