xxxxxxxxxx
use Illuminate\Support\Facades\File;
public function upload(Request $request)
{
$request->validate([
'zipFile' => 'required|mimes:zip|max:2048'
]);
if ($request->hasFile('zipFile')) {
$file = $request->file('zipFile');
$fileName = $file->getClientOriginalName();
$folderName = 'custom-folder'; // Specify your custom folder name here
$folderPath = public_path('templates/' . $folderName);
// Check if the folder already exists
if (File::exists($folderPath)) {
// Delete the existing folder and its contents
File::deleteDirectory($folderPath);
}
// Create the folder
File::makeDirectory($folderPath, 0755, true, true);
$filePath = public_path('templates/' . $folderName . '/' . $fileName);
$file->move($folderPath, $fileName);
// Additional operations with the uploaded file
return "File uploaded successfully!";
}
return "No file uploaded.";
}
xxxxxxxxxx
use Illuminate\Support\Facades\File;
public function upload(Request $request)
{
$request->validate([
'zipFile' => 'required|mimes:zip|max:2048'
]);
if ($request->hasFile('zipFile')) {
$file = $request->file('zipFile');
$fileName = $file->getClientOriginalName();
$folderName = 'custom-folder'; // Specify your custom folder name here
$folderPath = public_path('templates/' . $folderName);
// Check if the folder already exists
if (File::exists($folderPath)) {
// Delete the existing folder and its contents
File::deleteDirectory($folderPath);
}
// Create the folder
File::makeDirectory($folderPath, 0755, true, true);
$filePath = public_path('templates/' . $folderName . '/' . $fileName);
$file->move($folderPath, $fileName);
// Additional operations with the uploaded file
return "File uploaded successfully!";
}
return "No file uploaded.";
}