Advertisement
rfv123

stackoverflow/questions/33012235/

Oct 8th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. $dirPath = 'c:/xampp\htdocs/lookinggood\public/img\testsave';
  3.  
  4. if (!file_exists($dirPath)) {  // make directory path
  5.   echo PHP_EOL, 'create path';
  6.   mkdir($dirPath, 0, true);
  7. }
  8. else {
  9.   echo PHP_EOL, 'path already exists: ', $dirPath;
  10. }
  11.  
  12. $file = $dirPath .'/2015-10-07-11-40-19-edit-one.jpg';
  13. if (!file_exists($file)) {
  14.    echo PHP_EOL, 'Creating file: ', $file, PHP_EOL;
  15.    touch($file);
  16. }
  17. else {
  18.    echo PHP_EOL, 'file already exists: ', $file, PHP_EOL;
  19. }
  20.  
  21. $fileInfo = new  SplFileInfo($file);
  22.  
  23. var_dump(PHP_EOL. 'Filepath: '. $file,  
  24.          PHP_EOL. 'file found: ', file_exists($file),
  25.          PHP_EOL. 'SplFileInfo:', $fileInfo,
  26.          PHP_EOL. 'SplFileInfo->readable:', $fileInfo->isReadable(),
  27.          PHP_EOL. 'SplFileInfo->writable:', $fileInfo->isWritable(),
  28.          __FILE__.__LINE__);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement