使用以下代码,我的浏览器返回"图像未创建或保存".我向你保证图像的位置存在.所以if语句中的行由于某种原因返回false,并且是安装了GD.有任何想法吗?
if ($img = @imagecreatefromjpeg("/var/www/images/upload/1/1.jpg")) {
die("image was created");
} else {
die ("image was not created or saved");
}
Run Code Online (Sandbox Code Playgroud)
好的,我这样做了:
<?php
error_reporting(E_ALL);
if (fopen('/var/www/images/upload/1/1.jpg')) {
echo 'file was opened';
} else {
echo 'file was not opened';
}
?>
Run Code Online (Sandbox Code Playgroud)
每次都没有打开返回文件,apache组拥有所有这些文件夹的所有权限.GD或PHP是不同的用户名?
从测试脚本执行is_readable()后,它返回true.还有什么问题呢?
所以...当我运行脚本时:
error_reporting(E_ALL);
imagecreatefromjpeg("/var/www/images/upload/1/1.jpg");
print_r(error_get_last());
echo ("hi");
Run Code Online (Sandbox Code Playgroud)
我收到了死亡白屏.如果我注释掉imagecreatefromjpeg行,屏幕会显示'hi'
刚尝试了500k jpg图像,看看它是否是内存问题,但仍然有白屏.
当我在if语句中运行imagecreatefromjpeg并通过终端运行脚本时,imagecreatefromjpeg成功!= \仍然无法弄清楚为什么它不会起作用.编辑:通过我的浏览器运行这个确切的脚本也是成功的.
因此,我正在尝试创建一个 div 类,该类将显示在一行中,然后在所有空间被占用时自动换行到下一行。
.contributor_thumbnail {
display: block;
float: left;
width: 150px;
height: 150px;
border: 1px solid #777;
}
Run Code Online (Sandbox Code Playgroud)
所以当我像这样调用代码时:
<div class="contributor_thumbnail">thumb here</div>
<div class="contributor_thumbnail">thumb here</div>
<div class="contributor_thumbnail">thumb here</div>
<div class="contributor_thumbnail">thumb here</div>
Run Code Online (Sandbox Code Playgroud)
div 将并排放置。
现在 div 只是重叠。有任何想法吗?
//Save new category information
$('.save_cat').live('click', function() {
cat_id = $(this).attr("id").slice(4);
cat_name = $(this).parent().prev().prev().children('.cat_name_edit').val();
sort_order = $(this).parent().prev().children('.sort_order_edit').val();
$.ajax({ type: 'POST',
url: '../file/category/update_category',
data: { 'cat_id' : cat_id,
'sort_order' : sort_order,
'cat_name' : cat_name},
beforeSend:function(){
//action while loading
},
success:function(data){
alert('hi');
$(this).html("Edit");
},
error:function(){
// failed request; give feedback to user
alert("An unexpected error has occurred. Your category could not be saved.");
},
dataType : 'json'
});
});
Run Code Online (Sandbox Code Playgroud)
在成功处理程序中,我试图将单击元素的html从Save更改为Edit.如果我将它直接放在.save_cat的单击处理程序下面,它可以正常工作.请求成功后我该怎么办?
我是一名PHP程序员,但我有兴趣深入了解算法和模式.我觉得PHP可能不是最好的语言.我应该学习哪种语言?为什么?
我正在编写一个规范,根据global.window的存在来测试javascript文件中的差异.有没有办法导入或需要两次特定文件?设置global.window之前和之后一次.
正在测试的文件看起来像这样:
let someObject = (windowExists => {
return windowExists ? 'abc' : '123';
})(typeof window !== 'undefined');
export default someObject;
Run Code Online (Sandbox Code Playgroud)
我希望使用这种模式,但看起来似乎并不可行,因为common.js和es6模块都只包含一次文件并且之后处理缓存版本.