Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isSet($letter['tmp_name'])&&(strcmp($letter['tmp_name'],'')!=0)) {
- //find the letter file. store it as $letteroriginal. $letterbackup is temporary location
- $letterfmt = FindFormat($config['uploadDir'], $idPaper, "l");
- $letteroriginal = "./".FNameLetter ($config['uploadDir'], $idPaper, $letterfmt);
- $letterbackup = "./" . $config['uploadDir'] . "backup1";
- // if the original exists move it to the backup.
- if(file_exists($letteroriginal){
- rename($letteroriginal, $letterbackup);
- $letterbackedup = TRUE;
- }
- if (StoreLetter ($id, $letter, $format, $db)) {
- // if the letter store sucessfully - and there was a backup - delete it
- if($letterbackedup) {
- unlink($letterbackup);
- }
- }
- else {
- // if the letter was backed up and the file didn't upload succesfully - revert it
- if($letterbackedup) {
- rename($backup, $original);
- }
- // return with error
- return "Unable to store the letter <br>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement