Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep original media filename after upload #2173

Closed
Luc45 opened this issue Nov 6, 2017 · 5 comments
Closed

Keep original media filename after upload #2173

Luc45 opened this issue Nov 6, 2017 · 5 comments

Comments

@Luc45
Copy link

Luc45 commented Nov 6, 2017

  • Laravel Version: 5.5.*
  • Voyager Version: 1.0.15
  • PHP Version: 7.2

Description:

Voyager media manager uses store() method from Laravel to save uploaded files.

The store() method encrypts the filename in a md5 hash with a random number from 0-999, thus generating a unique filename.

However, I would like to upload the file while preserving it's name.

I'm opening this issue to request an option on Voyager config for that. :)

Changing:

if (in_array($request->file->getMimeType(), $allowedImageMimeTypes)) {
    $file = $request->file->store($request->upload_path, $this->filesystem);

    $image = Image::make($realPath.$file);

    if ($request->file->getClientOriginalExtension() == 'gif') {
        copy($request->file->getRealPath(), $realPath.$file);
    } else {
        $image->orientate()->save($realPath.$file);
    }
} else {
    $file = $request->file->move($realPath, $request->file->getClientOriginalName());
}

To
$file = $request->file->move($realPath, $request->file->getClientOriginalName());

In the upload method, at:
voyager/src/Http/Controllers/VoyagerMediaControler.php:176

Uploads the file while preserving it's name

@fletch3555
Copy link
Collaborator

All fields are required when opening issues: https://github.com/the-control-group/voyager/blob/master/ISSUE_TEMPLATE

Please update your issue description with the missing data and we'll reopen this

@Luc45
Copy link
Author

Luc45 commented Jun 24, 2018

@fletch3555 Sorry, I haven't seem your answer. Issue updated with version details.

@fletch3555
Copy link
Collaborator

This issue is almost 8 months old... are you still having the same problem with the same version....?

@baljitkaur19
Copy link

Just add the below line in the field under Tools->Database->edit bread field name options
{
"preserveFileUploadName": "yes"
}

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants