有点标题党,不过确实是一个不错的多文件上传类。简洁实用。 这个类可以用来处理表单上传多个文件。 这个类可以检查文件是否不为空,也没有超过给定的大小限制。 它也可以检查文件类型对允许和拒绝的文件类型列表。 该类还可以通过用下划线代替空格使最终的文
有点标题党,不过确实是一个不错的多文件上传类。简洁实用。
这个类可以用来处理表单上传多个文件。
这个类可以检查文件是否不为空,也没有超过给定的大小限制。
它也可以检查文件类型对允许和拒绝的文件类型列表。
该类还可以通过用下划线代替空格使最终的文件名更安全。
如果在上传文件时出现错误,类抛出一个异常对象,该对象提供有关错误代码和说明错误消息的信息。
代码珠玑:http://www.codepearl.com/files/194.html
源码与演示:源码出处 演示出处


<?php //http://www.codepearl.com $action = isset($_GET['action'])?$_GET['action']:""; require_once('main.class.php'); $auc = new auc(); if ($action == 'uploadfile') { $auc = new auc(); //Comment: $auc->upload_dir("directory name", "create dir if it does not exist, false by default or true"); //$auc->upload_dir("/path/to/uploads/folder/with/trailing/slash/", false); //Comment: $auc->make_safe = true || false (default); make the file name safe //$auc->make_safe = true; //Comment: $auc->max_file_size = size in bytes (1MB default) || false; set max file size in bytes or false not to check size //$auc->max_file_size = 1048576; //Comment: $auc->overwrite = true || false (default); overwrite if file exists //$auc->overwrite = true; //Comment: $auc->check_file_type = false (default) || allowed || denied; //$auc->check_file_type = 'allowed'; $result = $auc->upload("file"); if (is_array($result)) { echo 'Something Went Wrong'; echo '<pre class="brush:php;toolbar:false">'; var_dump($result); echo ''; } else { echo 'All OK'; } } else { ?>
<?php //http://www.codepearl.com class auc { public $errors = array(); //array used to store any errors that occur. public $upload_dir = ''; //the upload_dir being used by the script public $make_safe = false; //default don't modify the file name to safe version public $max_file_size = 1048576; //Max File Size in Bytes, 1MB public $overwrite = false; //default don't overwrite files that already exsist public $check_file_type = false; //don't check for file type by default but can check for allowed and denied files. public $allowed_mime_types = array('image/jpeg', 'image/png', 'image/gif', 'image/tiff'); //array of allowed mime types used when check_file_type is set to allowed public $denied_mime_types = array('application/x-php', 'text/html'); //array of denied mime types used when check_file_type is set to denied /** * Check if the upload dir is valid, if it is not valid attempt to make the dir, if dir is succesfully created chmod it to 0777. * If any elments fail return false else set upload_dir and return true. * @param string $dir * @param boolean $mkdir * @return true or false */ public function upload_dir($dir, $mkdir = false) { $errors =& $this->errors; $status = true; if (!is_dir($dir)) { if ($mkdir) { if (!mkdir($dir)) { $status = false; } else { if (!chmod($dir, 0777)) $status = false; } } else { $status = false; } } if ($status) { $this->upload_dir = $dir; return true; } else { $errors['general'][] = 'Upload Dir is Not Valid and/or a dir could not be created/chmod.'; return false; } } /** * check that the upload dir is valid and that it is writeable * * @param string $dir * @return true or false */ public function check_dir($dir) { if (!is_dir($dir) || !is_writable($dir)) return false; return true; } /** * make the uploaded file name safe * * @param string $file_name * @return safe file name */ public function make_safe($file_name) { return str_replace(' ', '_', $file_name); } /** * Check the Attemted Uploads for errors etc if everything goes good move the file, to the upload_dir. * * @param array $object * @return unknown */ public function upload($object) { $errors =& $this->errors; if (empty($errors['general'])) { if (empty($this->upload_dir)) $this->upload_dir = dirname(__FILE__).'/'; //if no default upload_dir has been specified used the current dir. if ($this->check_dir($this->upload_dir)) { $files = $_FILES[$object]; $count = count($files['name']) - 1; echo '<pre class="brush:php;toolbar:false">'; var_dump($files); echo ''; for ($current = 0; $current max_file_size) { if ($files['size'][$current] >= $this->max_file_size) throw new TrigerErrorException($files['name'][$current].' exceeds defined max_file_size', $files['name'][$current]); } if ($this->check_file_type == 'allowed' && !in_array($files['type'][$current], $this->allowed_mime_types)) { throw new TrigerErrorException($files['name'][$current].' is not an allowed type', $files['name'][$current]); } elseif ($this->check_file_type == 'denied' && in_array($files['type'][$current], $this->denied_mime_types)) { throw new TrigerErrorException($files['name'][$current].' is a denied type', $files['name'][$current]); } //if make_safe is true call make safe function if ($this->make_safe) $files['name'][$current] = $this->make_safe($files['name'][$current]); //if overwrite is false and the file exists error if (!$this->overwrite && file_exists($this->upload_dir.$files['name'][$current])) throw new TrigerErrorException($files['name'][$current].' already exsists', $files['name'][$current]); //move the uploaded file, error if anything goes wrong. if (!move_uploaded_file($files['tmp_name'][$current], $this->upload_dir.$files['name'][$current])) throw new TrigerErrorException($files['name'][$current].' could not be moved', $files['name'][$current]); } catch (TrigerErrorException $e) { $errors[$files['name'][$current]][] = $e->Message(); } } if (empty($errors)) { //return true if there where no errors return true; } else { //return the errors array if there where any errros return $errors; } } else { //return false as dir is not valid $errors['general'][] = "The Specified Dir is Not Valid or is Not Writeable"; return false; } } } } /** * Handle the Exceptions trigered by errors within upload code. * */ class TrigerErrorException extends Exception { protected $file = ""; public function __construct($message, $file = "", $code = 0) { $this->file = $file; parent::__construct($message, $code); } public function Message() { return "{$this->message}"; } } ?>

作者:楚怡、凯衡等近日,美团视觉智能部研发了一款致力于工业应用的目标检测框架YOLOv6,能够同时专注于检测的精度和推理效率。在研发过程中,视觉智能部不断进行了探索和优化,同时吸取借鉴了学术界和工业界的一些前沿进展和科研成果。在目标检测权威数据集COCO上的实验结果显示,YOLOv6在检测精度和速度方面均超越其他同体量的算法,同时支持多种不同平台的部署,极大简化工程部署时的适配工作。特此开源,希望能帮助到更多的同学。1.概述YOLOv6是美团视觉智能部研发的一款目标检测框架,致力于工业应用。

5月2日消息,目前大多数AI聊天机器人都需要连接到云端进行处理,即使可以本地运行的也配置要求极高。那么是否有轻量化的、无需联网的聊天机器人呢?一个名为MLCLLM的全新开源项目已在GitHub上线,完全本地运行无需联网,甚至集显老电脑、苹果iPhone手机都能运行。MLCLLM项目介绍称:“MLCLLM是一种通用解决方案,它允许将任何语言模型本地部署在一组不同的硬件后端和本地应用程序上,此外还有一个高效的框架,供每个人进一步优化自己用例的模型性能。一切都在本地运行,无需服务器支持,并通过手机和笔

作为一个技术博主,了不起比较喜欢各种折腾,之前给大家介绍过ChatGPT接入微信,钉钉和知识星球(如果没看过的可以翻翻前面的文章),最近再看开源项目的时候,发现了一个ChatGPTWebUI项目。想着刚好之前没有将ChatGPT接入过WebUI,有了这个开源项目可以拿来使用,真是不错,下面是实操的安装步骤,分享给大家。安装官方在Github的项目文档上提供了很多中的安装方式,包括手动安装,docker部署,以及远程部署等方法,了不起在选择部署方式的时候,一开始为了简单想着

深度推荐模型(DLRMs)已经成为深度学习在互联网公司应用的最重要技术场景,如视频推荐、购物搜索、广告推送等流量变现业务,极大改善了用户体验和业务商业价值。但海量的用户和业务数据,频繁地迭代更新需求,以及高昂的训练成本,都对 DLRM 训练提出了严峻挑战。在 DLRM 中,需要先在嵌入表(EmbeddingBags)中进行查表(lookup),再完成下游计算。嵌入表常常贡献 DLRM 中 99% 以上的内存需求,却只贡献 1% 的计算量。借助于 GPU 片上高速内存(High Bandwidth

自从Midjourney发布v5之后,在生成图像的人物真实程度、手指细节等方面都有了显著改善,并且在prompt理解的准确性、审美多样性和语言理解方面也都取得了进步。相比之下,StableDiffusion虽然免费、开源,但每次都要写一大长串的prompt,想生成高质量的图像全靠多次抽卡。最近StabilityAI的官宣,正在研发的StableDiffusionXL开始面向公众测试,目前可以在Clipdrop平台免费试用。试用链接:https://clipdrop.co/stable-diff

在人类的感官中,一张图片可以将很多体验融合到一起,比如一张海滩图片可以让我们想起海浪的声音、沙子的质地、拂面而来的微风,甚至可以激发创作一首诗的灵感。图像的这种「绑定」(binding)属性通过与自身相关的任何感官体验对齐,为学习视觉特征提供了大量监督来源。理想情况下,对于单个联合嵌入空间,视觉特征应该通过对齐所有感官来学习。然而这需要通过同一组图像来获取所有感官类型和组合的配对数据,显然不可行。最近,很多方法学习与文本、音频等对齐的图像特征。这些方法使用单对模态或者最多几种视觉模态。最终嵌入仅

刚刚,哥伦比亚大学系统生物学助理教授 Mohammed AlQuraishi 在推特上宣布,他们从头训练了一个名为 OpenFold 的模型,该模型是 AlphaFold2 的可训练 PyTorch 复现版本。Mohammed AlQuraishi 还表示,这是第一个大众可用的 AlphaFold2 复现。AlphaFold2 可以周期性地以原子精度预测蛋白质结构,在技术上利用多序列对齐和深度学习算法设计,并结合关于蛋白质结构的物理和生物学知识提升了预测效果。它实现了 2/3 蛋白质结构预测的卓

当前,非英文文图生成模型选择有限,用户往往要将prompt翻译成英语再输入模型。这样不仅会造成额外的操作负担,并且翻译过程中的语言文化误差,会影响生成图片的准确性。智源研究院FlagAI团队首创高效训练方式,使用多语言预训练模型和StableDiffusion结合,训练多语言文图生成模型——AltDiffusion-m18,支持18种语言的文图生成。包括中文、英文、日语、泰语、韩语、印地语、乌克兰语、阿拉伯语、土耳其语、越南语、波兰语、荷兰语、葡萄牙语、意大利语、西班牙语、德语、法语、俄语。Hu


Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

AI Hentai Generator
Menjana ai hentai secara percuma.

Artikel Panas

Alat panas

VSCode Windows 64-bit Muat Turun
Editor IDE percuma dan berkuasa yang dilancarkan oleh Microsoft

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

MantisBT
Mantis ialah alat pengesan kecacatan berasaskan web yang mudah digunakan yang direka untuk membantu dalam pengesanan kecacatan produk. Ia memerlukan PHP, MySQL dan pelayan web. Lihat perkhidmatan demo dan pengehosan kami.

Notepad++7.3.1
Editor kod yang mudah digunakan dan percuma

Penyesuai Pelayan SAP NetWeaver untuk Eclipse
Integrasikan Eclipse dengan pelayan aplikasi SAP NetWeaver.