fopen,extbase,typo3-4.5 , can't create files in typo3 inside fileadmin


can't create files in typo3 inside fileadmin

Question:

Tag: fopen,extbase,typo3-4.5

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


Answer:

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:


fopen and 'a+' mode in php?


php,pointers,fopen
Consider the code below (file test.txt doesn't exist): $fp = fopen('test.txt', 'a+'); echo ftell($fp); // 0 fwrite($fp, "abc\n"); fclose($fp); I run the code once - echo ftell($fp); // 0, I run the code again - echo ftell($fp); // 0 still returns 0. The file now contains abc\nabc\n, so I would...

Extbase: inject repository into domain model


extbase
I am currently working with Typo3 6.2.10 and Extbase. I am trying to inject a repository into my domain model like this: class MyModel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { /** * @inject * @var \Vendor\Package\Domain\Repository\SomeRepository */ protected $someRepository; } However, $this->someRepository is always null. Injecting repositories into controllers always works though. Thank...

Call a PHP from another PHP (without cURL)


php,json,curl,fopen
I have a HTML page that has to call a PHP on another domain. The "Same-Origin-Rule" of most browsers prohibits that call. So I want to call a PHP on my domain to call a PHP on the target domain. I want to avoid cURL so I decided to use...

stat(), fstat(), lstat(), and fopen(); how to write TOCTOU protected system independent code


c,fopen,fstat
I've been dealing with a problem for a few weeks now updating 20 year code that needs to be system independent (work on both Linux and Windows). It involves Time-of-Check, Time-of-Use (TOCTOU) issues. I made a thread here, but it didn't go very far, and after ruminating on it for...

Typo3 - extbase - Missing type information, probably no @param annotation for parameter “$currentPage”


annotations,typo3,extbase,typo3-6.2.x
I get the following error in Typo3 Backend: Missing type information, probably no @param annotation for parameter "$currentPage" in Tx_OptivoBm_Controller_NewsletterController->newAction() The function is set up like that: /** * action new * * @param $currentPage * @param $newNewsletter * @dontvalidate $newNewsletter * @return void */ public function newAction($currentPage) { if...

cURL headers in command line show content-type as image/png, in PHP shows text/html?


php,curl,fopen,fwrite
I'm attempting to use cURL to download an external image file. When used from the command line, cURL correctly states the response headers with content-type=image/png. When I attempt to use cURL in PHP however, it returns content-type=text/html. When attempting to save the file using cURL in PHP, with the CURLOPT_BINARYTRANSFER...

Shuffle and Display the Contents of .txt File


php,file,fopen
I am trying to read, shuffle, then display the contents of a text file. The text file contains a list of codes (each one on a new line - no commas etc). 1490 1491 1727 364 466 //... 783 784 786 My code: $file = fopen("keywords.txt", "r"); shuffle($file); while (!feof($file))...

Typo3 6.2 fluid pagination not working as expected


typo3,fluid,extbase,typo3-6.2.x,typo3-4.5
My typo3 6.2(Upgraded from Typo3 4.5) fluid paginate displays all the items instead of 5 items. My Repository Method : public function getRandomLocation($iLimit) { $query = $this->createQuery(); $result = $query->statement("Select * FROM tx_sfel_domain_model_ttblocationsproduktegruppen WHERE hidden = 0 AND deleted = 0 AND logo != '' ORDER BY uid LIMIT 0,...

How can I render preview of FE plugin diplayed in Page module


typo3,backend,extbase,typo3-6.2.x,typo3-extensions
I have developed TYPO3 (6.2) extensions with some FE plugins. I need to change informations about plugin, which is displayed in the backend on page view. Now only Title and name of plugin is displayed ... I have used flexforms for configure the plugin and I would like to show...

How can I most efficiently read the first n lines of a large text file in php?


php,fopen,fgets,fread,feof
So far I'm able to return the entire file, or an empty string. But not the first n lines of a file as expected. echo head('/path/to/my_file.txt',100); // returns '', or in other versions `1\n1\n...` function head($filepath, $lines = 1, $adaptive = true) { // Open file $f = @fopen($filepath, "rb");...

Matlab Crahes upon fopen in Mex File


c,matlab,fopen,mex
I have a little experience with Matlab, but am new to the mex environment. What I am trying to do is to save some values I compute to a txt file in my C routine. For the sake of simplicity I am using the example arrayProduct.c from MathWork's Create C...

PHP file opening error


php,file,fopen
Ok, so I have looked everywhere for an answer to this question and can not find it. So I have a php file on my godaddy website. The second I add this line of code to it: $myfile = fopen("fileName.txt", "r") or die("Unable to open file!"); It prints out this...

How to open a file with append mode only if it exist


c++,c,fopen
The function fopen("file-name",a); will return a pointer to the end of the file. If the file exist it is opened, otherwise a new file is created. Is it possible to use the append mode and open the file only if it already exist? (and return a NULL pointer otherwise). Thanks...

How I can write a html code (templete) to a html file by php? [closed]


php,html,fopen,fwrite,fclose
How I can write html code (not executable) to a file by using php filesystems. For example I want to put my html page template which includes DOCTYPE, HEADER, BODY BLOCK, FOOTER etc.

How to get typo3 settings in the utility files?


php,typo3,fluid,extbase
plugin.tx_xxx { setting { storagePid = 23 } } I want this typo3 settings in utility file. Please help me....

How to get all FAL File Objects which are referenced?


repository,typo3,extbase,fal
I'm trying to make a extbase extension for TYPO3 to get alle file objects with mimetype image/... which referenced by any content, plugin or fluid in typo3. But i don't know which is the best way to get these data. How should i create a model in my extension and...

Typoscript USER / USER_INT objects in powermail input fields


typoscript,fluid,extbase,typo3-6.2.x
I've a custom extension to render a value from database. I want to prefill the returned value of the extension using powermail prefill typoscript. But when I add the plugin as userfunction, then it will display strange output in frontend. See my typoscript code below; lib.companyname = USER_INT lib.companyname {...

PHP error “Cannot redeclare class” in extbase-based extension of Typo3 4.7


php,typo3,extbase
I have created an extension for Typo3 4.7 (actually, it was created for Typo3 6.2, but I am trying to backport it) using the extbase framework. I have already removed all namespaces from the core and also checked TYPO3 - Call another repository. However, I have the problem that calling...

Trying to create file in directory in C, but file is not being created


c,fopen
I have been searching for hours and hours now and cannot figure out why this is not working. I want to create a file in C, in a directory I created, but the file is not being created. Here is the relevant code pertaining to making the directory and creating...

get all image source from a website in php


php,image,domdocument,fopen,src
What I want to do is let the user type a url which has images such as https://www.flickr.com/search/?text=arushad%20ahmed , and get all the image source in the 'src' attribute and display it. The following approach didn't work: $file = fopen("https://www.flickr.com/search/?text=arushad%20ahmed", "r"); $doc = new DOMDocument(); $doc->loadHTML($file); $image = $doc->getElementsByTagName('img'); foreach...

Should I fclose(file) if an error occured?


c,file,file-io,fopen,fclose
Code: FILE *fp = fopen(filename, "r"); if (!fp) { fprintf(stderr, "Failed to open a file\n"); // fclose(fp) <-- should I close file here? exit(1); } // Some operations on the file. fclose(fp); Question: If fopen() fails to open a file, should I still call fclose()?...

Receiving error code during output redirection using execvp


c,exec,fopen,io-redirection,dup2
I am trying to redirect the output from ls to a file, in a shell I created in C. I type in: ls > junk and what I get out is: ls: cannot access >: No such file or directory Then if I use CTRL-D to exit the shell it...

Display Extbase FileReference with Fluid


typo3,fluid,extbase,typo3-6.2.x
In an extbase extension, I have a FileReference Object. It was created with extension_builder originally. From The Model: /** * apprenticeshipDocument * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference */ protected $apprenticeshipDocument = NULL; etc. In the frontend, <f:debug>{institution.apprenticeshipDocument}</f:debug> gives me this: First Thing: originalResource is missing. Second: When calling {institution.apprenticeshipDocument.uidLocal} directly, the value is...

fopen() works, dio_open() doesn't?


php,file,fopen
Seeing some issues running fopen() when dio_open() is working just fine. Here's a test script I wrote to check the issue as it was appearing in a new installation I'm trying to get working. <?php echo "Current User: " . get_current_user() . "<br/>"; echo "UID: " . getmyuid() . "<br/>";...

PHP filter hashtags from string and write result back to file


php,filter,fopen,fwrite,word
I'm using fopen() and fwrite() to write some JSON content to a file. My question: Is there a way to filter the content and write only specific words to that file? E.g.: I retrive "I #love #love #love you so #much my dear #brother!" from the JSON file and I...

How can I use an injected object in the constructor?


typo3,extbase
I have a service class in my Extbase extension and want to use the ObjectManager to create an instance of an object in the constructor. /** * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface * @inject */ protected $objectManager; public function __construct() { $this->standaloneView = $this->objectManager->get('TYPO3\CMS\Fluid\View\StandaloneView'); $this->standaloneView->setFormat('html'); } Unfortunately this doesn't fails with an error...

How to open a text file from matlab to view?


matlab,fopen
I am having a text file and I want to view it through Matlab command instead of opening it through the file manager. I have tried the following: fid= fopen('exp.txt','r'); But its not opening. Any anyone help me with this? Thanks....

Best way to store the first and second word of a text file into two arrays


c,arrays,char,fopen,fscanf
I'm making a code for a program. It would have three text files: -list1.txt having a column of words like: Cat Dog Fish Computers -change.txt having two columns of text like Dog Marbles Computers Store -list2.txt being empty The program would take list.txt, and store its words in the list2.txt,...

Can we open a binary file in C without fopen?


c,binary,fopen
In C programming, can we open a binary file without fopen() , only with open ? Because I need a file descriptor, not a filestream. Thank you...

PHP: file_put_contents and writing to multiple files in a for loop not working


php,fopen,file-put-contents
For some background I have a bit of code that I am using to generate html files that contain a link to a unique code. Ultimately this ends up on a USB drive thats distributed to customers. This is done in batch so i can create as many custom files...

findAll on non object in extbase


repository,extbase,findall,typo3-4.5
I just created an extension in typo3 4.5 with one model (product). I created the "productRepository" then injected it in the ProductController but I still get the Call to a member function findAll() on a non-object here is how the ProductController looks like : /** * @var Tx_PiProductDetail_Domain_Repository_ProductRepository */ protected...

Read the file error C_language


c,file,fopen
i am trying to create file and write some data on it, but when i run the following code program runs to error: Error 1 error C2664: 'errno_t fopen_s(FILE **,const char *,const char *)' : cannot convert argument 1 from 'FILE *' to 'FILE **' #include "stdafx.h" #include <stdio.h> #include...

Ignoring return value of fscanf and Segmentation fault


c,segmentation-fault,fopen,compiler-warnings,fscanf
I was wondering how to solve a Core dumped issue on my C code. When I compile it with: g++ -g MatSim.cpp -o MatSim -lstdc++ -O3, I get three warnings, this is one (The other two are similar and are only differentiated by the string variable name): MatSim.cpp: In function...

fopen mode w+ and reading the file?


php,fopen,mode
I'm going through all the modes and trying to understand where can you apply some of them, and I stumbled upon w. Now I understand how that mode works, but what's the purpose of w+? Obviously if we use fopen right after opening the file, it won't work since the...

C Segfault in readdir after chdir


c,fopen,readdir,chdir
I am having a weird issue with this C program I'm writing to loop through a directory and open each file to do some work on. My program is located in the parent directory of the directory I'm searching through. In order for fopen to be able to see the...

Saving File to Folder using PHP


php,dictionary,fopen,tcpdf
Few examples I've tried // Worked fopen($OutputFolderPath."Text.pdf", "w"); // Didn't work $pdf->Output($OutputFolderPath . $Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname'] . '_' . $Mother->PatientTableRecord['NHSID'] . ' ' . date('d_m_Y') . '.pdf','F'); // $OutputFolderPath . $Mother->PatientTableRecord['Forename'] . ' ' . $Mother->PatientTableRecord['Surname'] . ' ' . date('d_m_Y h_i_s', time()) . '.pdf','F' // Works...

can't create files in typo3 inside fileadmin


fopen,extbase,typo3-4.5
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...

How to disable cache for a image carousel in TYPO3


caching,typo3,typoscript,extbase,typo3-6.2.x
My TYPO3 extension has a lib that generates random 5 images from the total stock, for example out of the 100 images. This is done randomly every time the page is loaded. Only default the TYPO3 cache is enabled so every time the same 5 images are showed. As the...

How to get filename in Typo3 solr extension with FAL and own Extbase extension


solr,typo3,extbase,typo3-6.2.x,fal
Before FAL, I can get the filename of an image from my own Extbase extension in the solr config file "typo3/ext/solr/Configuration/TypoScript/Solr/setup.txt" via index { queue { tx_myextension = 1 tx_myextension { fields { ... myimage_stringS = articleimage ... } } } } Where "articleimage" was a database field with the...

TYPO3 extbase create url in repository (not controller)


typo3,extbase
There are good tutorials on how to create URL's in the controllers like this one. Examples are: $this->uriBuilder->reset()->setTargetPageUid($page_uid)->setCreateAbsoluteUri(TRUE)->build(); $this->controllerContext->getUriBuilder()->reset()->setTargetPageUid($page_uid)->setArguments(array('person'=>$person->getUid())->buildFrontendUri(); In works from the controller. But I cannot do the same work in a repository. Error log say that reset() in first example and getUriBuilder in second example is called on...

Segmentation fault on fopen C [duplicate]


c,file,fopen
This question already has an answer here: When using gets to get a file name in C, the file opens but when using fgets it does not 3 answers guy's well I have this code #include <stdio.h> typedef struct { int numero, notaF, notaE; char nome[100]; } ALUNO; void...

TYPO3 Extbase build own Sitemap


typo3,sitemap,extbase
There are a lot of sitemap Generators for TYPO3 in the TER available. But none of them can handle Sites created by Extbase, which are not shown in the TYPO3 page tree. Edit Thanks to biesior, detailed informations: Unconventional I switch in TypoScript the GET Parameter for my Extbase extension[globalVar...

Trying to use fopen and fprintf with matlab, only writing once


matlab,input,printf,fopen
I'm having trouble writing to a file here... I must be making a simple mistake but I can't find it. Anyways, here's the code: ages = 1; while (ages > 0) fileID = fopen('age.txt', 'w'); %opens file ages = input('Enter an age (negative to quit): '); %user input if(ages >...

Read lines from file not return all


c,fopen,readfile,fgets
I'm trying to keep the words from a file into an array but I only read the first 8. My code below. #define BUF 128 /* can change the buffer size as well */ char ** readFileContentArray(char* filename){ int lines = 128; char ** strLines = (char **)malloc(sizeof(char*)*lines); FILE *plist...

File I/O in C - How to read from a file and then write to it?


c,file-io,fopen,fgetc
I'm new to file i/o in C, and in my code I want to read information from a text file and then write to it. I tried to open a csv file using fopen("file.csv", "r+t") in order to be able to read and then write to the same file. So...

How to use Hook “processDatamap_postProcFieldArray” in TYPO3 6.x


php,typo3,extbase,typo3-6.2.x
Use case: When saving an object (in backend, maybe in frontend too later) I want to manipulate values before saving to database. Problem: The file seems to get included (shows an error on save if I choose a wrong file path) but the function does not seem to be executed...

How does my frontend usergroup list get lost between Extbase action controller and Fluid template partial in TYPO3 6.2?


typo3,fluid,extbase,typo3-6.2.x,typo3-extensions
I'm using TYPO3 CMS 6.2.12 and Extension Builder 6.2.0 to model a Report class and build an extension to manage it. One of the domain driven design requirements is that a report author be a logged-in front end user. A second requirement is that the author choose a single group...

Typo3 extbase database query


typo3,extbase,typo3-6.2.x,queryinterface
I have an extbase database query like below. $query = $this->createQuery(); $result = $query->statement("Select * FROM table1 WHERE hidden = 0 AND deleted = 0 AND (".$PublicationYears.") AND logo != '' ORDER BY uid ASC LIMIT 0, ".$iLimit." ")->execute(); return $result; $PublicationYears = "ttra = '12' or ttra = '13'...

Using FAL in Extbase correctly


typo3,extbase,fal
Domain model class Image extends AbstractContent { /** * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference */ protected $file; /** * Gets the image file * * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference */ public function getFile() { return $this->file; } /** * Sets the image file * * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file * @return void */ public function setFile($file)...