我把$file改成$form_data后,就会出现如下的错误,郁闷啊 Warning: fopen("", "r") - No error in D:\web\web.xiang3.com\cbg\biscuit\emp\update.php on line 18Warning: fread(): supplied argument is not a valid File-Handle resource in D:\web\web.xiang3.com\cbg\biscuit\emp\update.php on line 18
TO: xizi2002(戏子=>影帝) 能不能帮我看看我的代码,看错误是出在哪个地方,应该怎么改,谢谢
Warning: stat failed for C:\WINNT\TEMP\php132.tmp (errno=2 - No such file or directory) in D:\web\web.xiang3.com\cbg\biscuit\emp\update.php on line 18 不是告诉你了吗? 没有TEMP文件夹,你在 C:\WINNT\添假一个TEMP不就ok了吗?
Warning: fopen("", "r") - No error in D:\web\web.xiang3.com\cbg\biscuit\emp\update.php on line 18Warning: fread(): supplied argument is not a valid File-Handle resource in D:\web\web.xiang3.com\cbg\biscuit\emp\update.php on line 18
能不能帮我看看我的代码,看错误是出在哪个地方,应该怎么改,谢谢
你是不是想将图片插入数据库?如果是这样,addslashes()在这里有什么用吗?语法: string addslashes(string str);返回值: 字符串函数种类: 资料处理
内容说明
本函数使需要让数据库处理的字符串,引号的部份加上斜线,以供数据库查询 (query) 能顺利运作。这些会被改的字符包括单引号 (')、双引号 (")、反斜线 backslash (\) 以及空字符 NUL (the null byte)。在,用<input type=file>上传上去的文件默认的扩展名为.tmp,你考虑过用copy()处理吗?
不是告诉你了吗?
没有TEMP文件夹,你在 C:\WINNT\添假一个TEMP不就ok了吗?
function upload_file($fileform, $dir)
{
//取得上传文件
$upload_file=$_FILES[$fileform]['tmp_name'];
//取已上传文件名
$file_name=$_FILES[$fileform]['name'];
//判断已存目录是否有同名文件,或有则改名(原名_2)
$count = strlen($file_name);
$suffix = $file_name[$count-3].$file_name[$count-2].$file_name[$count-1];
$uploadDir = dir($dir);
while (false !== ($entry = $uploadDir->read()))
{
if($file_name==$entry)
{
for($i=0; $i<($count-4); $i++)
$tempFile=$tempFile.$file_name[$i];
$realFileName=$tempFile."_2.".$suffix;
$file_name=$realFileName;
}
}
$uploadDir->close();
//判断文件是否图片JPG、GIF、BMP、PNG
$fileSuffix = array('jpg','JPG','bmp','BMP','gif','GIF','png','PNG');
$count = strlen($file_name);
$suffix = $file_name[$count-3].$file_name[$count-2].$file_name[$count-1];
$countArray = count($fileSuffix);
for ($i=0; $i<=$countArray; $i++)
{
if ($suffix==$fileSuffix[$i])
$yes=1;
}
if ($yes!=1)
{
return 2;
exit;
}
//移动已经上传的文件到指定文件夹
if (move_uploaded_file($upload_file,$dir.$file_name))
{
chmod($dir.$file_name, 0644);
return $file_name;
}else{
return 0;
}
}