Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Name Change #36

Open
GoogleCodeExporter opened this issue May 22, 2015 · 0 comments
Open

File Name Change #36

GoogleCodeExporter opened this issue May 22, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1.Send any attachment with the same name

What is the expected output? What do you see instead?
The system should change the file name. The system overwrites existing files 
with the same name.  

Please provide any additional information below.
I added the following function to the system to fix the issue. I am still 
learning so the code may not be perfect, but it works great.

public function checkFileName($filename){
    $fullFileName = dirname( __FILE__ ).'/save_dir/'.$filename;
    if(file_exists($fullFileName)){
        $exists='1';$check='';
        $splitFile = explode('.',$filename);
        $count = count($splitFile);
        $counter = $count-1;;
        $piece = $splitFile[$counter];
        $file='';
        for($i=0;$i<$count-1;$i++){
            $file.=$splitFile[$i];
        }
        $i='1';
        while($exists='1'){
            $check = $file.'('.$i.').'.$piece;
            $name=dirname( __FILE__ ).'/save_dir/'.$check;
            if(!file_exists($name)){break;}
            else{$i++;}
        }
        $filename=$check;
    }
    return $filename;
}

Original issue reported on code.google.com by [email protected] on 24 Apr 2013 at 6:02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant