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

Slim\Http\UploadedFile - no way to retrieve client-provided full path to the file #1798

Closed
ConstantineYurevich opened this issue Mar 5, 2016 · 12 comments

Comments

@ConstantineYurevich
Copy link
Contributor

Previously it was at least possible to use public variable $this->file.

Now there is not way to retrieve full path at all.

@ConstantineYurevich
Copy link
Contributor Author

If $this->file was removed from public access, you should add some getter, I guess.

@akrabat
Copy link
Member

akrabat commented Mar 5, 2016

oh, good catch!

@akrabat
Copy link
Member

akrabat commented Mar 5, 2016

I'm not sure that this property should be public in the next version though. What's the use-case for needing it?

@ConstantineYurevich
Copy link
Contributor Author

My particular example is importing CSV file using http://csv.thephpleague.com/examples/ library (one of the most popular libraries for working with files).

I want to import CSV data without uploading file to S3 (I'm using stateless container-based architecture) using following code:

<?php

use League\Csv\Reader;

$csv = Reader::createFromPath($uploadedFile->getClientFileTmpName());

Where path should be tmp_path from UploadedFile object (which is not available now).

@ConstantineYurevich
Copy link
Contributor Author

Previously I used it this way:

<?php

use League\Csv\Reader;

$csv = Reader::createFromPath($uploadedFile->file);

akrabat added a commit that referenced this issue Mar 5, 2016
@akrabat
Copy link
Member

akrabat commented Mar 5, 2016

Fixed and 3.2.2 is now released.

I'm sorry for the inconvenience that this caused you.

@ConstantineYurevich
Copy link
Contributor Author

Maybe it makes sense to create getter for this field, and make usage of public property deprecated?

@akrabat
Copy link
Member

akrabat commented Mar 5, 2016

Probably. We need to look at it, but I didn't want to slow down the release of 3.2.2.

@merumelu
Copy link

merumelu commented Mar 5, 2016

It is possible to get the temp path with $uploadedFile->getStream()->getMetadata('uri'), but this is rather verbose. A simple getter would be nice.

@zoolyka
Copy link

zoolyka commented Dec 16, 2020

Just for the record, in Slim v4 you can use $uploadedFile->getFilePath() to get the (temp) location of an uploaded file.

@l0gicgate
Copy link
Member

@zoolyka Slim 4 doesn't ship with a PSR-7 implementation so that wouldn't be a valid statement. Whichever PSR-7 implementation you have installed would provide that method.

@zoolyka
Copy link

zoolyka commented Dec 16, 2020

@l0gicgate correct, thanks. I referred to the "default" slim/psr7 implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants