uguu/core.php

17 lines
569 B
PHP
Raw Normal View History

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