Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-Move_上传的文件Move带有无法理解的符号的文件_Php - Fatal编程技术网

PHP-Move_上传的文件Move带有无法理解的符号的文件

PHP-Move_上传的文件Move带有无法理解的符号的文件,php,Php,我有一个移动文件功能的问题 问题是,若我上传一个阿拉伯语文件,它会显示一些无法理解的符号 看这幅画 对此不是100%确定,但是当您从文件数组接收字符串时,是否尝试过对文件名进行编码 http://php.net/manual/en/ref.url.php 幸运的是,有一些库可以解决这个问题,比如 谢谢你@meda 这是我的密码 我收到的信 <?php set_time_limit(0); require("connect.php"); if (isset($_FILES['upl

我有一个移动文件功能的问题

问题是,若我上传一个阿拉伯语文件,它会显示一些无法理解的符号

看这幅画


对此不是100%确定,但是当您从文件数组接收字符串时,是否尝试过对文件名进行编码

http://php.net/manual/en/ref.url.php

幸运的是,有一些库可以解决这个问题,比如

谢谢你@meda 这是我的密码

我收到的信

    <?php
set_time_limit(0);
require("connect.php");
if (isset($_FILES['upload_file'])) {
    foreach ($_FILES['upload_file']['tmp_name'] as $count=>$upload_file) {
            if (!empty($_FILES['image']['error'][$count])) {
            // Some error occured with the file in index $count
            // Put some error handling in here...
            return false; // or you could continue;
        }

        if (!empty($upload_file)&&is_uploaded_file($upload_file)) {
    $charset="AHfgG15Ds10MZD58N";
            $code='';
            $length=15;
            for ($i=0; $i<=$length; $i++) {
                $rand=rand()%strlen($charset);
                $tmp=substr($charset,$rand,1);
                $code.=$tmp;
            }
             mysql_query("SET NAMES utf8");
            $query=mysql_query("SELECT `code` FROM `files`  WHERE `code`='$code'") or die(mysql_error());
            $numrows=mysql_num_rows($query);

            while ($numrows!=0) {
                $code='';
                for ($i=0; $i<=$length; $i++) {
                    $rand=rand()%strlen($charset);
                    $tmp=substr($charset,$rand,1);
                    $code.=$tmp;
                }
                $query=mysql_query("SELECT `code` FROM `files`  WHERE `code`='$code'");
                $numrows=mysql_num_rows($query);
            }
            $types = array('jpg','jpeg','gif','png','zip','rar','mp3','m4a','wmv','divx','mp4','flv','FLV','dvd','mkv','bmp','xml','doc','pdf','xls','psd','svg','3gp','ppt','txt','exe','mpeg','dvdrip');
            $names = pathinfo($_FILES['upload_file']['name'][$count]);
            if (in_array($names['extension'],$types)) {
            mkdir("upload/$code/");
            $name=$_FILES["upload_file"]["name"][$count];
            $type=$_FILES["upload_file"]["type"][$count];
            $size=$_FILES["upload_file"]["size"][$count];
            $tmp_name=$_FILES["upload_file"]["tmp_name"][$count];
            if ($size < 600000000)
            {
            $site_url=('http://localhost');
            $url= ("$site_url/download.php?file=$code");
            mysql_query("SET NAMES utf8");
            $query=mysql_query("INSERT INTO files VALUES ('Null','$name','$code','$type','$size','$url')");
            $url=urlencode($name);
            if($upload = move_uploaded_file($upload_file ,"upload/$code/".$name))
            {

            if ($upload) { ?>
                <table>
                <tr>
                <td><h3>File name</h3></td><td><h3>File Link</h3></td><td><h3>File Type</h3></td>
                </tr>
                <tr>
                <td><?php echo"$name"; ?></td><td> <?php echo"<a href='http://localhost/downoald.php?file=$code' target='_blanck'>File Link</a>"; ?></td><td><?php print_r ($names['extension']); ?></td>
                </tr>
                </table>
            <?php } else { ?>
                No file selected
            <?php }

                        }else{
            echo "A problem occurred while uploading your file(s), please try again."; 
            }
            }else{
            echo "This file(s) is up to 1GB<br>";
            }
}else{
echo "Type of the file not allowed"; 
}
}else{
echo "this error is fan";
}
}
} 
?>

显示一些代码会很好。另外,如果您找不到问题的解决方案,您可以随时将文件重命名为数字格式。但是,您有一个编码问题。请尝试使用您应该只使用“答案”按钮发布答案,但此代码有什么问题请编辑我的代码。我的问题是文件以阿拉伯语保存在数据库中,并以无法理解的符号移动到文件夹中。你需要实现我给你的代码,如果你遇到问题,你应该告诉我出了什么问题。我的问题是我设置的代码他不工作。请这样做,给我完整的代码。非常感谢。当然,你不会告诉我这个错误,我应该知道?PHP5不能…,这里有一个用PHP5编写的库,它就是这样做的。呃@deceze我的意思是没有库,我的英语不是很完美,你知道库只是用PHP编写的PHP代码,对吗?你可以在你的应用程序中自己编写代码来做同样的事情,那么你就不需要库了。。。只是您需要注意某些事情才能使其正常工作,而不是PHP没有能力。
    <?php
set_time_limit(0);
require("connect.php");
if (isset($_FILES['upload_file'])) {
    foreach ($_FILES['upload_file']['tmp_name'] as $count=>$upload_file) {
            if (!empty($_FILES['image']['error'][$count])) {
            // Some error occured with the file in index $count
            // Put some error handling in here...
            return false; // or you could continue;
        }

        if (!empty($upload_file)&&is_uploaded_file($upload_file)) {
    $charset="AHfgG15Ds10MZD58N";
            $code='';
            $length=15;
            for ($i=0; $i<=$length; $i++) {
                $rand=rand()%strlen($charset);
                $tmp=substr($charset,$rand,1);
                $code.=$tmp;
            }
             mysql_query("SET NAMES utf8");
            $query=mysql_query("SELECT `code` FROM `files`  WHERE `code`='$code'") or die(mysql_error());
            $numrows=mysql_num_rows($query);

            while ($numrows!=0) {
                $code='';
                for ($i=0; $i<=$length; $i++) {
                    $rand=rand()%strlen($charset);
                    $tmp=substr($charset,$rand,1);
                    $code.=$tmp;
                }
                $query=mysql_query("SELECT `code` FROM `files`  WHERE `code`='$code'");
                $numrows=mysql_num_rows($query);
            }
            $types = array('jpg','jpeg','gif','png','zip','rar','mp3','m4a','wmv','divx','mp4','flv','FLV','dvd','mkv','bmp','xml','doc','pdf','xls','psd','svg','3gp','ppt','txt','exe','mpeg','dvdrip');
            $names = pathinfo($_FILES['upload_file']['name'][$count]);
            if (in_array($names['extension'],$types)) {
            mkdir("upload/$code/");
            $name=$_FILES["upload_file"]["name"][$count];
            $type=$_FILES["upload_file"]["type"][$count];
            $size=$_FILES["upload_file"]["size"][$count];
            $tmp_name=$_FILES["upload_file"]["tmp_name"][$count];
            if ($size < 600000000)
            {
            $site_url=('http://localhost');
            $url= ("$site_url/download.php?file=$code");
            mysql_query("SET NAMES utf8");
            $query=mysql_query("INSERT INTO files VALUES ('Null','$name','$code','$type','$size','$url')");
            $url=urlencode($name);
            if($upload = move_uploaded_file($upload_file ,"upload/$code/".$name))
            {

            if ($upload) { ?>
                <table>
                <tr>
                <td><h3>File name</h3></td><td><h3>File Link</h3></td><td><h3>File Type</h3></td>
                </tr>
                <tr>
                <td><?php echo"$name"; ?></td><td> <?php echo"<a href='http://localhost/downoald.php?file=$code' target='_blanck'>File Link</a>"; ?></td><td><?php print_r ($names['extension']); ?></td>
                </tr>
                </table>
            <?php } else { ?>
                No file selected
            <?php }

                        }else{
            echo "A problem occurred while uploading your file(s), please try again."; 
            }
            }else{
            echo "This file(s) is up to 1GB<br>";
            }
}else{
echo "Type of the file not allowed"; 
}
}else{
echo "this error is fan";
}
}
} 
?>