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

getTargetFilename() error #5

Closed
tazzkiller opened this issue Jul 6, 2019 · 2 comments
Closed

getTargetFilename() error #5

tazzkiller opened this issue Jul 6, 2019 · 2 comments
Labels

Comments

@tazzkiller
Copy link

If withTargetFilename() is not set on upload, getTargetFilename() don't return the random name generated

@ocram
Copy link
Contributor

ocram commented Jul 6, 2019

Thank you!

This is actually expected and desired behavior, but perhaps poorly documented.

You could call save twice on the same instance and it would upload with two different random names that are generated at the time when the actual upload is requested, not when the upload is described initially. So what it returns is only the filename you have set yourself (explicitly). Thus it also allows you to check if you have already set a name.

We could change this behavior, but I’m not sure if that’s really necessary.

Why would you need the random file name even before the upload has been processed? As shown in the README, it’s easy to get the generated name as soon as it has actually been created:

$uploadedFile = $upload->save();
$generatedRandomName = $uploadedFile->getFilenameWithExtension();

@ocram ocram added question and removed enhancement labels Aug 9, 2020
@ocram
Copy link
Contributor

ocram commented Aug 9, 2020

No need for any changes here

@ocram ocram closed this as completed Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants