与PHP项目相关 [英] Related to PHP project

查看:40
本文介绍了与PHP项目相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

我正在进行一些项目。假设我有一个新文件夹,我在文件夹中有很多文本文件,我想要一个PHP代码,如果文件不是空的话应该验证文件是否为空如果应该存储在数据库中,如果文件是空的,它应该存储在数据库中的其他表中。像这样它应该验证所有的文本文件。任何帮助都是可以接受的。



我尝试了什么:



Hi.
I am proceeding with some project. suppose i have a new folder i have many text file inside the folder, i want a php code where it should validate whether the file is empty if the file is not empty if should get stored in database, and if the file is empty it should get stored in some other table in the database. like this it should validate for all the text file. any help will be acceptable.

What I have tried:

<?php
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        // basename() may prevent filesystem traversal attacks;
        // further validation/sanitation of the filename may be appropriate
        $name = basename($_FILES["pictures"]["name"][$key]);
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
?>

推荐答案

uploads_dir = ' / uploads';
foreach
uploads_dir = '/uploads'; foreach (


_FILES [ pictures] [ error] as
_FILES["pictures"]["error"] as


key =>
key =>


这篇关于与PHP项目相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆