chmod到777但仍然获得图片上传权限 [英] chmod to 777 but still get permission denied on image upload
问题描述
我一直在使用以下功能(是的,它不够优雅,我说的很多,我说的很久以前就写过了)上传图片。它至少有一年的时间没有问题,而且我不记得最近在任何时候将它更改为b $ b。然而,剧本突然在这个
行上死了:
if(copy($ uploadedFile,$ pathToImageFolder)){
这是我得到的错误:
警告:无法访问
/home/www/krubner/atp/mcIncludes/mcImages.php在线199
我的第一个想法是检查权限 - 它们被设置为755,但是
来测试它们是否是问题我将它们更改为777.再次尝试>
并遇到同样的问题。所以我加入了这行,你会看到下面的
,我试图回应这些值。这就是我得到的:
这里是文件名,这里是文件夹
/ home / krubner / www / atp / mcImages /
没有文件名。我认为这是问题所在,但为什么还有
突然没有文件名? (我正在运行PHP的4.2.3版本,如果你要求b $ b请求)。
函数uploadImage(){
extract($ config = getConfig());
全球$表格,$ io,$ users,$ links,$ sql,$ uploadedFile,
$ uploadedFile_size,$ uploadedFile_name,$ overRide;
$ uploadedFile_name = processFileName($ uploadedFile_name);
$ uploadedFile_name = htmlspecialchars($ uploadedFile_name);
if($ uploadedFile_size> 10000000&& $ overRide!=" true"){
startPage("此图片非常大,超过10兆字节。你确定
你要继续吗?");
echo"
< div class =''dvclMcWholeForm''>
< form method =''post''action =''$ self''enctype =''multipart / form-data''
class =''mcForm'' >
上传此图片:< br>
< input type =''file''name =''uploadedFile''> < br>< br>
< input type =''hidden''name =''choiceMade''value =''uploadImage''>
< input type =''hidden''name =''overRide''value =''true''>
< input type =''submit''value =''上传文件''>
< / form>
< / div>
" ;;
endPage ();
} else {
$ pathToImageFolder。= $ uploadedFile_name;
$ imagesFolder。= $ uploadedFile_name;
echo"< br>< br>< br>< br>这里是文件名$ uploadedFile_name和
这里''文件夹$ pathToImageFolder" ;;
if(copy($ uploadedFile,$ pathToImageFolder) ))
startPage();
echo"
< div class =''mcForm''>
图片或文件已上传。如果你想参考它
这是地址:< br>< br>
< a href =''$ imagesFolder''>
$ imagesFolder
< / a>
< BR>< BR>
链接代码这个图像看起来像这样:< br>< br>
& lt; img src =''$ imagesFolder''& gt;
< ; br>< br>
将此代码放在您希望显示此图像的任何页面上:
< br>< br>
< img src =''$ imagesFolder''>
< br>< br>
ALT标签控制鼠标时出现的文字光标在图像上悬停
。如果你输入& lt; img src =''myImage.jpg''
ALT =''在夏洛茨维尔市中心拍摄的照片''& gt;然后单词
''在夏洛茨维尔市中心拍摄的照片'出现了。
< a href =''http://www.htmlhelp.com/reference /wilbur/syntax.html''>You
可以在htmlHelp.com上阅读有关IMG标签语法的更多信息< / a>
< br>< br>
另请注意,如果您希望图像浮动在
列的中间,只需将标记& lt; center& gt;在它之前和标签
& lt; / center& gt;在它之后。 (希望所有这些代码编写都将在此软件的未来版本中自动生成;现在,
对不起朋友们,但是你必须亲自编辑这些标签。你想要
它们与下面列出的不同。)
< / div>
" ;;
endPage();
} else {
全球$表单,$ io,$ users,$ links,$ sql,$ users;
startPage();
echo"
< div class =''mcForm''>
由于某种原因,上传失败。这个问题可能是暂时的
或永久性问题。再试一次。
< / div>
" ;;
endPage();
}
}
}
函数printFormForImageUpload(){
extract ($ config = getConfig());
//我们需要打印表格
startPage("注意:某些图像类型不能在网络上运行上传
图片有''jpe''或'jpg''或''jpeg''或''gif''或''png''作为他们的
endings。");
echo"
< div class =''dvclMcWholeForm''>
< form method =''post''action =''$ self''enctype =''multipart / form-data''
class =''mcForm''>
上传此图片:< br>
< input type =''file''name =''uploadedFile''>< br>< br>
< input type =''hidden''name =''choiceMade''value =''uploadImage''>
&l t;输入类型='''提交''价值=''上传文件''>
< / div>
" ;;
endPage();
}
I''ve been using the following function (yes, it is inelegant, what can
I say, I wrote it a long time ago) to upload images. Haven''t had a
problem with it for at least a year, and I don''t recall changing it
anytime recently. Nevertheless, the script is suddenly dying on this
line:
if (copy($uploadedFile, $pathToImageFolder)){
This is the error I get:
Warning: Unable to access in
/home/www/krubner/atp/mcIncludes/mcImages.php on line 199
My first thought was to check permissions - they were set to 755, but
to test if they were the problem I changed them to 777. Tried again
and got the same problem. So then I added in the line, you''ll see it
below, where I try to echo out the values. This is what I get:
here''s the file name and here''s the folder
/home/krubner/www/atp/mcImages/
There is no file name. I assume that is the problem, but why is there
suddenly no file name? (I''m running version 4.2.3 of PHP, if you''re
asking).
function uploadImage() {
extract($config = getConfig());
global $forms, $io, $users, $links, $sql, $uploadedFile,
$uploadedFile_size, $uploadedFile_name, $overRide;
$uploadedFile_name = processFileName($uploadedFile_name);
$uploadedFile_name = htmlspecialchars($uploadedFile_name);
if ($uploadedFile_size > 10000000 && $overRide != "true") {
startPage("This image is very large, over 10 megabyte. Are you sure
you want to proceed?");
echo "
<div class=''dvclMcWholeForm''>
<form method=''post'' action=''$self'' enctype=''multipart/form-data''
class=''mcForm''>
Upload this image: <br>
<input type=''file'' name=''uploadedFile''><br><br>
<input type=''hidden'' name=''choiceMade'' value=''uploadImage''>
<input type=''hidden'' name=''overRide'' value=''true''>
<input type=''submit'' value=''Upload File''>
</form>
</div>
";
endPage();
} else {
$pathToImageFolder .= $uploadedFile_name;
$imagesFolder .= $uploadedFile_name;
echo "<br><br><br><br> here''s the file name $uploadedFile_name and
here''s the folder $pathToImageFolder ";
if (copy($uploadedFile, $pathToImageFolder)) {
startPage();
echo "
<div class=''mcForm''>
The image or file has been uploaded. If you wish to reference it
this is the address:<br><br>
<a href=''$imagesFolder''>
$imagesFolder
</a>
<BR><BR>
The code for a link to this image would look like this:<br><br>
<img src=''$imagesFolder''>
<br><br>
Put this code on any page where you want this image to appear:
<br><br>
<img src=''$imagesFolder''>
<br><br>
The ALT tag controls what text appears when the mouse cursor hovers
over an image. If you type <img src=''myImage.jpg''
ALT=''Photo taken in downtown Charlottesville''> then the words
''Photo taken in downtown Charlottesville'' are what appear.
<a href=''http://www.htmlhelp.com/reference/wilbur/syntax.html''>You
can read more about IMG tag syntax on htmlHelp.com</a>
<br><br>
Also note that if you want an image to float in the middle of a
column, just put the tag <center> before it and the tag
</center> after it. (Hopefully all this code writing will be
automated in future versions of this software; for now,
sorry folks, but you''ve got to hand edit these tags if you want
them any different than how they are listed below.)
</div>
";
endPage();
} else {
global $forms, $io, $users, $links, $sql, $users;
startPage();
echo "
<div class=''mcForm''>
For some reason the upload failed. This problem might be temporary
or permanent. Try again.
</div>
";
endPage();
}
}
}
function printFormForImageUpload() {
extract($config = getConfig());
// We need to print the form
startPage("Note: certain image types don''t work on the web. Upload
images that have ''jpe'' or ''jpg'' or ''jpeg'' or ''gif'' or ''png'' as their
endings.");
echo "
<div class=''dvclMcWholeForm''>
<form method=''post'' action=''$self'' enctype=''multipart/form-data''
class=''mcForm''>
Upload this image: <br>
<input type=''file'' name=''uploadedFile''><br><br>
<input type=''hidden'' name=''choiceMade'' value=''uploadImage''>
<input type=''submit'' value=''Upload File''>
</div>
";
endPage();
}
推荐答案
uploadedFile,
uploadedFile,
pathToImageFolder)){
这是我得到的错误:
警告:无法访问
/ home / www / krubner / atp / mcIncludes / mcImages.php在第199行
我的第一个想法是检查权限 - 它们被设置为755,但是
来测试它们是否是问题是我把它们改成了777.再试一次
并得到了同样的问题。所以我加入了这行,你会看到下面的
,我试图回应这些值。这就是我得到的:
这里是文件名,这里是文件夹
/ home / krubner / www / atp / mcImages /
没有文件名。我认为这是问题所在,但为什么还有
突然没有文件名? (我正在运行PHP的4.2.3版本,如果你要求b $ b请求)。
函数uploadImage(){
extract(
pathToImageFolder)){
This is the error I get:
Warning: Unable to access in
/home/www/krubner/atp/mcIncludes/mcImages.php on line 199
My first thought was to check permissions - they were set to 755, but
to test if they were the problem I changed them to 777. Tried again
and got the same problem. So then I added in the line, you''ll see it
below, where I try to echo out the values. This is what I get:
here''s the file name and here''s the folder
/home/krubner/www/atp/mcImages/
There is no file name. I assume that is the problem, but why is there
suddenly no file name? (I''m running version 4.2.3 of PHP, if you''re
asking).
function uploadImage() {
extract(
config = getConfig());
global
config = getConfig());
global
这篇关于chmod到777但仍然获得图片上传权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!