Open Budolfsen opened 5 years ago
What you can do is retrieve the filename first then setName.
Without original filename
// Optionally you can rename the file on upload
$new_filename = uniqid('GK' . '-');
$file->setName($new_filename);
With original filename
// Optionally you can rename the file on upload
$original_filename = $file->getName();
$new_filename = uniqid('GK' . '-');
$file->setName($new_filename);
$original_filename = $file->getName();
I replaced $file->setName($new_filename)
with $file->setName($original_filename)
, but it did not upload and did not overwrite the old images.
I need to upload the new image with the same name to overwrite the old image with the same name. I do not want to use unique ID.
Maybe you are doing something wrong, Can you show the code snippet?
Hi I am trying to use this on a project and it works fine with uploading the files with the unique id - but I was wondering how I can get it to use the uploaded files name and write it to the database.
This is my code (controller, text-model and imagemodel)
Text controller:
My textmodel
My image model (billedemodel)
It uploads the files as it should with uniq-id but I can't get it to write the name to the database.
Can anyone help - please