How we timestamp rename in this laravel controller?
I Want to rename my file so that wherever the name exists or used it’s name for some functions in the whole laravel file that also should be changed by the new name. How do i do that in laravel
<code>foreach ($files as $file) {
$extension = $file->getClientOriginalExtension();
$check = in_array($extension, $allowedFileExtension);
if ($check) {
if ($extension == 'csv') {
$name = Str::random(40) . '.' . $extension;
$file->move(storage_path() . '/app/form-values/' . $form->id, $name);
$values[] = 'form-values/' . $form->id . '/' . $name;
} else {
$path = Storage::path("form-values/$form->id");
if (!file_exists($path)) {
mkdir($path, 0777, true);
chmod($path, 0777);
}
if (!file_exists(Storage::path($fileName))) {
mkdir(Storage::path($fileName), 0777, true);
chmod(Storage::path($fileName), 0777);
}
$values[] = $fileName;
}
</code>
<code>foreach ($files as $file) {
$extension = $file->getClientOriginalExtension();
$check = in_array($extension, $allowedFileExtension);
if ($check) {
if ($extension == 'csv') {
$name = Str::random(40) . '.' . $extension;
$file->move(storage_path() . '/app/form-values/' . $form->id, $name);
$values[] = 'form-values/' . $form->id . '/' . $name;
} else {
$path = Storage::path("form-values/$form->id");
if (!file_exists($path)) {
mkdir($path, 0777, true);
chmod($path, 0777);
}
if (!file_exists(Storage::path($fileName))) {
mkdir(Storage::path($fileName), 0777, true);
chmod(Storage::path($fileName), 0777);
}
$values[] = $fileName;
}
</code>
foreach ($files as $file) {
$extension = $file->getClientOriginalExtension();
$check = in_array($extension, $allowedFileExtension);
if ($check) {
if ($extension == 'csv') {
$name = Str::random(40) . '.' . $extension;
$file->move(storage_path() . '/app/form-values/' . $form->id, $name);
$values[] = 'form-values/' . $form->id . '/' . $name;
} else {
$path = Storage::path("form-values/$form->id");
if (!file_exists($path)) {
mkdir($path, 0777, true);
chmod($path, 0777);
}
if (!file_exists(Storage::path($fileName))) {
mkdir(Storage::path($fileName), 0777, true);
chmod(Storage::path($fileName), 0777);
}
$values[] = $fileName;
}
New contributor
neo4ru is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.