Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a14aa6eb98 | |||
| 99a30e4d9f |
@@ -32,3 +32,7 @@ auth.json
|
|||||||
# File XLSX temporanei importati
|
# File XLSX temporanei importati
|
||||||
/public/userarea/imported_trf/*.xlsx
|
/public/userarea/imported_trf/*.xlsx
|
||||||
/public/userarea/xlstemplates/*.xlsx
|
/public/userarea/xlstemplates/*.xlsx
|
||||||
|
|
||||||
|
# Ignora cartelle di foto generate
|
||||||
|
/public/photostrf/
|
||||||
|
/public/photostrf/qrcodes/
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
<?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']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 571 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 92 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 510 B |
|
Before Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 515 B |
|
Before Width: | Height: | Size: 509 B |
|
Before Width: | Height: | Size: 508 B |
|
Before Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 510 B |
|
Before Width: | Height: | Size: 516 B |
|
Before Width: | Height: | Size: 512 B |
|
Before Width: | Height: | Size: 518 B |
|
Before Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 517 B |
|
Before Width: | Height: | Size: 513 B |
|
Before Width: | Height: | Size: 510 B |
|
Before Width: | Height: | Size: 514 B |