]>
jfr.im git - uguu.git/blob - core.php
2 function save_file ($file, $name){
4 $path='/home/neku/www/files/';
5 //Generate prefix, put together name and remove tags/whitespace
6 $file_name = strip_tags(preg_replace('/\s+/', '', $name));
7 $file_name = gen_name($file_name);
8 while(file_exists($path.$file_name)){
9 $file_name = gen_name(file_name
);
11 //Move the file to the above location with said filename
12 move_uploaded_file($file,$path.$file_name);
13 //Return url+filename to the user
14 echo 'http://a.uguu.se/'.$file_name;
16 Function gen_name ($in){
17 //Generate random prefix
18 $chars = 'abcdefghijklmnopqrstuvwxyz';
20 for ($i = 0; $i < 6; $i++
) {
21 $name .= $chars[mt_rand(0, 25)];