Project

General

Profile

Actions

Bug #99404

closed

Invalide relative path given by getPublicUrl()

Added by Florian Rival almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
Start date:
2022-12-21
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

On a FileReference, if you try to get the public Url with :

$myFile->getOriginalResource()->getPublicUrl()

you get a relative URL like this :

'/uploads/tx_myext/MyTestFile.pdf'

but this URL is prefixed with a slash and then cannot be used with functions like fopen()

Before TYPO3 V11, the method getPublicUrl() return a path like this :

'uploads/tx_myext/MyTestFile.pdf'

Actions #1

Updated by Christoph Lehmann almost 2 years ago

If you wanna work with a file in the filesystem, then you can do it like this

// Path to local file (either original or copied to some temporary local location
$filePath = $file->getStorage()->getFileForLocalProcessing($file);

getPublicUrl() returns a publicly accessible URL for this file and it is not meant to be used in filesystem context.

Is it okay to close the issue for this reason?

Actions #2

Updated by Florian Rival almost 2 years ago

Thanks for you answer.

In my case, it works with that :

$myFile->getOriginalResource()->getForLocalProcessing();

You can close this issue.

Actions #3

Updated by Chris Müller almost 2 years ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF