Advertisement
Guest User

Untitled

a guest
Feb 6th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1.  if (isSet($letter['tmp_name'])&&(strcmp($letter['tmp_name'],'')!=0)) {
  2.  
  3.  
  4.   //find the letter file.  store it as $letteroriginal. $letterbackup is temporary location
  5.    $letterfmt = FindFormat($config['uploadDir'], $idPaper, "l");
  6.    $letteroriginal = "./".FNameLetter ($config['uploadDir'], $idPaper, $letterfmt);
  7.    $letterbackup = "./" . $config['uploadDir'] . "backup1";
  8.  
  9.  
  10.    // if the original exists move it to the backup.
  11.    if(file_exists($letteroriginal){
  12.         rename($letteroriginal, $letterbackup);
  13.         $letterbackedup = TRUE;
  14.    }
  15.  
  16.    if (StoreLetter ($id, $letter, $format, $db)) {
  17.    
  18.      // if the letter store sucessfully - and there was a backup - delete it
  19.      if($letterbackedup) {
  20.         unlink($letterbackup);
  21.       }
  22.    }
  23.    else {
  24.  
  25.      // if the letter was backed up and the file didn't upload succesfully - revert it
  26.      if($letterbackedup) {  
  27.      rename($backup, $original);
  28.      }
  29.      // return with error
  30.      return "Unable to store the letter <br>";  
  31.    }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement