php使用redis为啥总是会出现错误?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php使用redis为啥总是会出现错误?相关的知识,希望对你有一定的参考价值。
环境:windows 7,mysql,Apache, php7.0使用了tp5.0的框架,报的页面错误,请稍后再试的错误用tp3.2的框架,报的Redis' not found的错误,无法实例化
你的php是VC6编译的 你的php_redis.dll是VC9编译的导致不兼容。 找个VC6的php_redis.dll或重装个VC9的php都可以。追问我的php版本是7.0的,怎么会是使用的V6
参考技术A redis类的路劲不对 实例化的时候没有好到这个类文件所以报错了追问那路径应该怎么改呢?我试过了相对路径和绝对路径,还是这样
追答可以放到第三方类库 或者你可以用import先加载再实例化
例如:
能不能加个扣扣或者什么,我想问清楚点。。。。。。
为啥我用这段php上传代码总是出现这个问题?
用的是下面的php代码:
<html>
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="file.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</html>
//file.php
<?php
$uploaddir = './var/';
echo $uploaddir ;
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo $uploadfile;
echo '<br>Come in <br>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
echo "File is valid, and was successfully uploaded.\n";
else
echo "Possible file upload attack!\n";
echo 'Here is some more debugging info:';
print_r($_FILES);
?>
但是上传后总是出现
/bt//bt/bb_qvod.png
Come in
Warning: move_uploaded_file(/bt/bb_qvod.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/ipower/public_html/bt/upload.php on line 12
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpZkTgsp' to '/bt/bb_qvod.png' in /home/ipower/public_html/bt/upload.php on line 12
Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => bb_qvod.png [type] => image/png [tmp_name] => /tmp/phpZkTgsp [error] => 0 [size] => 1050 ) )
还有如何控制上面的文件上传类型
$uploaddir = './var/';
这一行代码和你显示出来的不一样。
你用的应该是虎翼网的空间吧。。如果你要上传到 bt 目录。直接这么写就可以了。
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $_FILES['userfile']['name'])) 参考技术B 给你个我写的上传类自已去看看吧
class upload
private $uploadFile; //上传路径
private $uploadType; //数组上传文件类型
private $uploadSize; //上传文件大小
public function __construct($uploadFile , $uploadType , $uploadSize)
$this->uploadFile = $uploadFile;
$this->uploadType = $uploadType;
$this->uploadSize = $uploadSize;
public function is_upload($name)
$error = new error();
if(!is_uploaded_file($_FILES[$name][tmp_name]))
return $error->alert_msg("文件上传不成功,请重新上传" , 1);
return true;
public function is_uploadSize($name)
$error = new error();
if($_FILES[$name]['size'] > $this->uploadSize)
echo $this->uploadSize;
return $error->alert_msg("文件太大了,请压缩后重新上传" , 1);
return true;
public function is_uploadType($name)
$fileType = explode( "." , $_FILES[$name]['name'] );
$count = (count($fileType) - 1);
$type = $fileType[$count];
for($i=0;$i<count($this->uploadType);$i++)
$retType .= $this->uploadType[$i].",";
$setType = trim($retType , ",");
$error = new error();
if(!in_array( $type , $this->uploadType ))
return $error->alert_msg("上传文件类型错误,只能上传".$setType."类型的文件,请重新上传" , 1);
return true;
public function uploading ($name)
$error = new error();
if($this->is_upload($name) && $this->is_uploadSize($name) && $this->is_uploadType($name))
if(!file_exists($this->uploadFile))
mkdir($this->uploadFile , 0777) or die("无法创建目录");
$fileName = date("Y-m-j" , time())."-".$_FILES[$name]['name'];
if(!file_exists($this->uploadFile."/".$fileName))
if(!move_uploaded_file ($_FILES[$name]['tmp_name'], $this->uploadFile."/".$fileName))
return $error->alert_msg("文件无法移动,请检查设置" , 1);
else
return $error->alert_msg("上传文件已存在,请重新上传" , 1);
return true;
参考技术C $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
去掉basename即可
最好是加个是否上传成功的判断本回答被提问者采纳 参考技术D if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
你这句是怎么移动的 没给文件名好么!!!! 第5个回答 2008-06-09 <form action="xxx.php" method="post" enctype="multipart/form-data">
少了这句吧enctype="multipart/form-data"
以上是关于php使用redis为啥总是会出现错误?的主要内容,如果未能解决你的问题,请参考以下文章
将静态图像添加到 php 邮件系统时,为啥会出现“意外 CID”错误?
为啥使用 Java 将数据发布到网站时会出现 405 错误?
对于缓存在redis中且不会改变的数据并发读为啥还会出现QPS的瓶颈