src/Codeception/Module/WPFilesystem.php
public function writeToUploadedFile($filename, $data, $date = null)
    {
        $filename = $this->getUploadsPath($filename, $date);
        $dir = dirname($filename);

        if (!is_dir($dir)) {
            if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
                throw new ModuleException(__CLASS__, "Could not create the [{$dir}] folder.");
            }
            $this->toClean[] = $dir;
        }

        if (file_put_contents($filename, $data) === false) {
            throw new ModuleException(__CLASS__, "Could not write data to file[{$filename}].");
        }

        return $filename;
    }
public function writeToUploadedFile($filename, $data, $date = null)
    {
        $filename = $this->getUploadsPath($filename, $date);
        $dir = dirname($filename);

        if (!is_dir($dir)) {
            if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
                throw new ModuleException(__CLASS__, "Could not create the [{$dir}] folder.");
            }
            $this->toClean[] = $dir;
        }

        if (file_put_contents($filename, $data) === false) {
            throw new ModuleException(__CLASS__, "Could not write data to file[{$filename}].");
        }

        return $filename;
    }
public function writeToUploadedFile ( $ filename , $ data , $ date = null ) { $ filename = $ this -> getUploadsPath ( $ filename , $ date ) ; $ dir = dirname ( $ filename ) ; if ( ! is_dir ( $ dir ) ) { if ( ! @ mkdir ( $ dir , 0777 , true ) && ! is_dir ( $ dir ) ) { throw new ModuleException ( __CLASS__ , "Could not create the [{$dir}] folder." ) ; } $ this -> toClean [ ] = $ dir ; } if ( file_put_contents ( $ filename , $ data ) === false ) { throw new ModuleException ( __CLASS__ , "Could not write data to file[{$filename}]." ) ; } return $ filename ; }
Writes a string to a file in the the uploads folder.

The date argument can be a string compatible with `strtotime` or a Unix
timestamp that will be used to build the `Y/m` uploads subfolder path.

@example
``` php
$I->writeToUploadedFile('some-file.txt', 'foo bar');
$I->writeToUploadedFile('some-file.txt', 'foo bar', 'today');
```

@param  string $filename The path to the destination file, relative to the current uploads folder.
@param  string $data The data to write to the file.
@param  string|int|\DateTime $date The date of the uploads to delete, will default to `now`.

@return string The absolute path to the destination file.

@throws \Codeception\Exception\ModuleException If the destination folder could not be created or the destination
file could not be written.
Writes a string to a file in the the uploads folder .