Files
crm.e5.pl/modules/EcmDocumentTemplatesaa/UploadFile.php
2024-04-27 09:23:34 +02:00

19 lines
532 B
PHP
Executable File

<?php
function upload_file($name, $toPath, $newName="") {
$file_tmp_name = $_FILES[$name]['tmp_name'];
$file_name = $_FILES[$name]['name'];
$file_size = $_FILES[$name]['size'];
if(is_uploaded_file($file_tmp_name)) {
$ext = strtolower(substr(strrchr($file_name, "."),1));
if($ext != "jpg" && $ext != "png") return '';
while(file_exists($p = $toPath.($guid=create_guid()).".".$ext));
move_uploaded_file($file_tmp_name, $p);
}
return $guid.'.'.$ext;
}
?>