Add php files
This commit is contained in:
18
modules/EcmDocumentTemplates/UploadFile.php
Executable file
18
modules/EcmDocumentTemplates/UploadFile.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user