2015-02-04 19:21:26 +00:00
|
|
|
<?php
|
|
|
|
function save_file ($file, $name){
|
2015-02-07 19:01:26 +00:00
|
|
|
//Generate a random set of numbers to set in front of the filename
|
2015-02-04 19:21:26 +00:00
|
|
|
$rand_string = crc32(microtime(true).mt_rand(1000, 9000));
|
2015-02-07 19:01:26 +00:00
|
|
|
//Where to save
|
2015-02-04 19:21:26 +00:00
|
|
|
$path='/home/neku/www/files/';
|
2015-02-07 19:01:26 +00:00
|
|
|
//Remove any tags
|
2015-02-04 19:21:26 +00:00
|
|
|
$file_data=strip_tags($file);
|
2015-02-07 19:01:26 +00:00
|
|
|
//Put together the random string+filename
|
2015-02-04 19:21:26 +00:00
|
|
|
$file_name=$rand_string.'_'.$name;
|
2015-02-07 19:01:26 +00:00
|
|
|
//Move the file to the above location with said filename
|
2015-02-04 19:21:26 +00:00
|
|
|
move_uploaded_file($file_data,$path.$file_name);
|
2015-02-07 19:01:26 +00:00
|
|
|
//Return url+filename to the user
|
2015-02-04 19:21:26 +00:00
|
|
|
echo 'http://a.uguu.se/'.$file_name;
|
|
|
|
}
|
|
|
|
?>
|