Files
crm.twinpol.com/modules/EcmDocumentTemplates/UploadFile.php
2025-05-12 15:44:39 +00: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;
}
?>