can't create files in typo3 inside fileadmin - fopen

I am building an extension with extbase where I need to create a pdf file inside fileadmin folder with php from a controller :
fopen("/fileadmin/pdf/anass.pdf", "w") or die('could not create file');
The permission is granted to write files ... so I think I made a mistake writing the path. Could somebody please help me?
PS: I am working on typo3 4.5

Indeed you're specifying absolute path in the filesystem and most probably there's no such path like /fileadmin/pdf/... there.
Quite safe would be using some TYPO3 constant to specify where's your app's root i.e. PATH_site, like:
fopen(PATH_site . "/fileadmin/pdf/anass.pdf", "w") or die('could not create file');
it will use the path like (sample)
/var/www/your-app/fileadmin/pdf/anass.pdf
note, that if you should use slash before fileadmin or not is OS/server config depended, so just check if your PATH_site ends with slash or not.

Related

Relative Paths in VS Code

I work with a multi-root workspace in VS Code. Here's my folder structure:
project-one
-node_modules
-public
--css
---styles.css
--img
---global
-----logo.svg
--js
---main.js
--index.html
project-two
project-three
When I reference files in my index.html file, VS Code always wants me to write it like this (in index.html):
src="img/global/logo.svg"
That doesn't really make sense to me. Logically, I would write the relative path to the logo with a leading / before img as the img folder is at the same level as index.html. However, that doesn't work.
Can anybody explain me why? And will the path declarations work correctly like this when I upload these files to the server (the content of the public folder will then be at the root)?
Thanks.

TYPO3 - Realurl default Settings overwrite?

How can I overwrite the default settings of the TYPO3 extension realurl with my own extension?
this dont work:
// RealUrl Config File
if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['realurl']['configFile'])
|| empty(trim($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['realurl']['configFile']))
) {
$GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['realurl']['configFile'] = 'typo3conf/ext/xxx/Resources/Private/Hooks/realurl_conf.php';
}
How can I use this?
Probably the problem is that realurl is inialized and executed very early (it's the first process which needs to translate the speaking url to url parameter which decide which page and which plugin is rendered).
Your attempt to modify the assignment which is done normaly in typo3conf/LocalConfiguration.php could not be attached to that file as it is just an array, which gets written anew automatically every now and then.
You might add that to typo3conf/AdditionalConfiguration.php.
But why don't you request an admin to assign the path to the config-file in your extension in the realurl EM-config by hand?

Loading file using a path writen in edit box matlab

hello evryone
wanna load file from a specific path writen in an edit box named by 'Load_text', i got the path from the edit box using :
pth=get(handles.Load_text,'string');
then i used 'dir' as follow:
S=dir(fullfile([pth '*.bmp']));
that what cause me an errur . so any ideas ?
If you want to load a file then why you are using dir?
Since you have the file's name, then you can create the fullpath as you do with the fullpath method and check its existence with exists.
If the file exists, then you can load it with all available methods from MATLAB.
Keep in mind that this means that the file is in the same directory as your GUI files. If it is in another then you will have to add it in the fullpath call.
fullpath online doc: http://www.mathworks.com/help/matlab/ref/fullfile.html
exists online doc: http://www.mathworks.com/help/matlab/ref/exist.html

How can I rename file uploaded to s3 using javascript api?

'pickAndStore' method allows me to specify full path to the file, but I don't know it's extension at this point (file path has to be defined before file is uploaded, so it's not possible to provide a path with correct extension).
if I use 'pick' and then 'store' I have 2 files (because both methods uploads file to the s3). I can delete 'old' file, but it's not optimal and can be pain (take ages) with really big files.
Is there any better solution? Ideally to rename existing file.
Currently, there is no workaround for renaming file.
However, in our Javascript API v2 we are planing to add new callback function. onStart callback will be fired after user pick file but before file uploading. There could be option like renaming file based on original filename.
We will keep you updated.

Autoloading classes in pimcore

I've created a fresh PHP-class, named it Application_Form_Login and saved it as Application_Form_Login.php inside the /website/lib directory. But everytime I'm running pimcore it refuses to load that file. What am I doing wrong here?
I've been looking at the Zend autoloader and trying to find out the issue.
I've noticed that in pimcore bootstrapping all the relevant directories are added to the include path. But they don't seem to get checked. Or maybe my file isn't named correctly to be picked up?
Your filename should be /website/lib/Application/Form/Login.php
From the page you just quoted:
Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.