javascript - IIS8+PHP+samba文件夹不能读写文件夹
问题描述
所以基本上我在xampp上构建了一个网页(php + js),让用户填写表格,并在该表格中他们可以上传多个图像。该站点运行良好,因此我使用 IIS8 将其上传到服务器上的生产环境。表单效果很好,但我无法上传或查看我上传的图像。
图像正在上传到 samba 驱动器,在 xampp 中我没有任何问题,它在 IIS 上的工作方式也是如此,我收到一条错误消息,说我没有权限。我不知道我做错了什么
这是获取图像的代码
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['id'])){
$id = $_POST['id'];
$directory = '\\\\server\\'.$id.'\\';
$directory = '\\\\server\\'.$id.'\\';
$local = glob("" . $directory . "{*.jpg,*.gif,*.png}", GLOB_BRACE);
$img_arr = array();
if($local){
$x=1;
}else{
$x=0;
}
foreach($local as $item)
{
$image = $item;
$imageData = base64_encode(file_get_contents($image));
$src = 'data: '.mime_content_type($image).';base64,'.$imageData;
$img_arr [] = array('mime'=> mime_content_type($image),'imgDt'=> $imageData);
}
}
if ($x==0){
$response = [
'status'=>'falhou',
'values' => $local
];
}else{
$response = [
'status'=>'sucesso',
'values' => $img_arr
];
}
header('Content-Type: application/json');
echo json_encode($response);
?>
这是添加图像的代码
if (!file_exists('\\\\server\\'.$tmstp)) {
mkdir('\\\\server\\'.$tmstp);
}
$uploadDir = '\\\\server\\'.$tmstp.'\\';
if(!empty($_FILES['anex'])){
foreach ($_FILES['anex']['name'] as $key=>$ficheiro) {
$fileName = basename($_FILES['anex']['name'][$key]);
$tmpname = $_FILES['anex']['tmp_name'][$key];
$targetFilePath = $uploadDir . $fileName;
$fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION);
$allowTypes = array('jpg', 'png', 'jpeg', 'gif');
if(in_array($fileType, $allowTypes)){
if(file_exists($targetFilePath)) {
//chmod($targetFilePath,0755); //Change the file permissions if allowed
unlink($targetFilePath); //remove the file
}
if(move_uploaded_file($tmpname, $targetFilePath)){
$uploadedFile = $fileName;
if ($i=0){
$anex=$fileName;
$i++;
$uploadStatus = 1;
$hf=true;
}
else{
$anex=$anex .';' . $fileName;
$uploadStatus = 1;
$hf=true;
$rspimg = 'Upload fotos com sucesso';
}
}else{
$uploadStatus = 0;
$rspimg = 'Ouve um erro com o UPLOAD das imagens';
}
}else{
$uploadStatus = 0;
$rspimg = 'Só JPG, JPEG, PNG ou GIF';
}
}
}else{
$hf = false;
}
我已经尝试在 IIS 上创建一个虚拟文件夹,但它仍然无法正常工作
解决方案
推荐阅读
- android - 浮动操作按钮强制图像到右下角而不是中心
- graphql - 是否可以在graphql的查询下添加一层分组?
- pagespeed-insights - 为什么 PSI API 将 originLoadingExperience 的值放在 loadingExperience 中,以防 CRuX 没有足够的页面实际速度数据?
- .net-core - 使用 Npgsql 和 CoreRT 编译 .Net Core 控制台应用程序
- git - 如何在 Azure DevOps 中为分支名称设置默认模板
- html - 如何使用 getELementsbyTagName 修复“每次”迭代?
- java - android.view.InflateException: Binary XML file line #11: Error inflating class ImageView
- glsl - 如果“缓冲区”是“连贯的”,那么读取字段或执行“atomicAdd(field, 0)”有什么区别吗?
- node.js - SSH 连接在第一次 exec() 后结束
- django - 接受任何查询集和字符串并在 queryset.string 上执行操作的函数