直到最近,我一直在使用一些PHP将照片上传到网站.但突然间它开始触发各种错误信息.
我使用on action的表单运行以下代码:
$uploaddir = "../../user_content/photo/";
$allowed_ext = array("jpeg", "jpg", "gif", "png");
if(isset($_POST["submit"])) {
$file_temp = $_FILES['file']['tmp_name'];
$info = getimagesize($file_temp);
} else {
print "File not sent to server succesfully!";
exit;
}
Run Code Online (Sandbox Code Playgroud)
表单的文件上载部分包含以下元素:
<input name="file" type="file" class="photo_file_upload">
Run Code Online (Sandbox Code Playgroud)
用于上载的提交按钮具有以下属性:
<button type="submit" name="submit" class="photo_upload">Upload</button>
Run Code Online (Sandbox Code Playgroud)
但每当我运行它时,我总会收到以下警告:
Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in (upload PHP file) on line 10
Run Code Online (Sandbox Code Playgroud)
(第10行是这部分:$ info = getimagesize($ file_temp);)
任何人对这是什么原因都有任何想法?
我正在使用动态数组,这是声明:
int *vetor = (int *) malloc (tam*sizeof(int));
vetorAleatorio (vetor, tam); //chamando função abaixo
Run Code Online (Sandbox Code Playgroud)
但是当我尝试将它作为参数传递给此函数时:
void vetorAleatorio(int **vet, int size) {
int i;
for (i=0; i<size; i++)
vet[i] = rand() %1000;}
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
[Warning] assignment makes pointer from integer without a cast
[Warning] passing arg 1 of `vetorAleatorio' from incompatible pointer type
Run Code Online (Sandbox Code Playgroud)
有人知道这是怎么回事吗?
我正在用David Haskins的一本名为"C in Linux"的书学习C,但是有一个问题.当我尝试编译此代码时:
#include <stdio.h>
#include <string.h>
int main (int argc, char *argv[], char *env[]) {
printf("Content-type:text/html\n\n<html><body bgcolor=#23abe2>\n");
char value[256] = "";
strncpy(value,(char *) getenv("QUERY_STRING"), 255);
printf("QUERY_STRING:%s<BR>\n", value );
printf("<form>\n");
printf("<input type=\"TEXT\" name=\"ITEM1\"> \n");
printf("<input type=\"TEXT\" name=\"ITEM2\"> \n");
printf("<input type=\"SUBMIT\">");
printf("</form></body></html>\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
终端显示此警告!
chapter4_1.c: In function ‘main’:
chapter4_1.c:14:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Run Code Online (Sandbox Code Playgroud) 不明白为什么我收到"控制可能达到无效功能的结束"的警告.有什么建议?
这是我的代码:
long double geo_fn(long reps, int seed) {
double x, y, pythag_sum, total = 0, inside = 0;
default_random_engine engine(seed);
uniform_real_distribution<double>dist(0,1);
for(int i = 0; i< reps ;i++){
x = dist(engine);
y = dist(engine);
pythag_sum = (x*x)+(y*y);
if (pythag_sum <= 1){
inside += pythag_sum;
total += pythag_sum;
}
else {
total += pythag_sum;
}
return (inside/total)/10;
}
}
Run Code Online (Sandbox Code Playgroud) 我在Eclipse中遇到关于"可能的空指针取消引用"的警告,但我真的不明白为什么.警告发生在最后一行的以下代码段中:
public void addMessage(Message message) {
WeakReference<MessagesPanelControl> view = null;
[...]
if(view != null && view.get() != null)
view.get().updateView();
}
Run Code Online (Sandbox Code Playgroud)
由于之前的检查,我完全确定,这view不能为空.Eclipse警告是:
错误:由于被调用的methodBug的返回值,AC.GUI.MessageHandler.addMessage(Message)中可能出现空指针取消引用:由于被调用方法的返回值,AC.GUI.MessageHandler.addMessage(Message)中可能出现空指针取消引用
如果它不是一个有效的警告,我怎么能抑制它?即使@SuppressWarnings("all")也不起作用.
我有一段代码,使用图像的alpha通道创建一个蒙版.在升级到Mavericks之前,它运行良好,我从未在Xcode调试控制台中收到任何警告或错误.自升级以来,我收到此警告:
从枚举类型'enum CGImageAlphaInfo'到不同的枚举类型'CGBitmapInfo'(又名'enum CGBitmapInfo')的隐式转换
标记为问题的行:
CGBitmapContextCreate(alphaData, width, height, 8, rowBytes, NULL, kCGImageAlphaOnly);
Run Code Online (Sandbox Code Playgroud)
这是文档为最后一个参数(aka kCGImageAlphaOnly)所说的内容:
bitmapInfo指定位图是否应包含Alpha通道,Alpha通道在像素中的相对位置以及有关像素组件是浮点值还是整数值的信息的常量.用于指定alpha通道信息的常量是使用
CGImageAlphaInfo类型声明的,但可以安全地传递给此参数.您还可以传递与该CGBitmapInfo类型关联的其他常量.
奇怪的是,在文档(图像的Alpha信息)中,Apple的typedef没有列出我正在使用的选项.但是,在随后的术语列表中,确实如此!这就是它所说的:
kCGImageAlphaOnly
没有颜色数据,只有alpha通道.适用于OS X v10.3及更高版本.宣布于CGImage.h.
考虑到我想创建一个alpha蒙版,我对任何颜色数据都不感兴趣,所以我使用的参数是唯一有意义的.我不确定它要我做什么.无论如何,该方法有效,并且当应用程序运行时一切都很好.话虽如此,警告真的很烦人.是否有一个特殊的CLANG指令让它沉默?任何帮助,将不胜感激.干杯.
如何重新编写代码来实现相同的测试,但便携避免该警告?
AFAIK,INT_MAX并且SIZE_MAX不定义成一个始终是> =比其他的,因此以下功能的使用,以检测问题从转换int到size_t.
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
size_t int_to_size_t(int size) {
assert(size >= 0);
#pragma GCC diagnostic ignored "-Wtype-limits"
// Without the above pragma, below line of code may cause:
// "warning: comparison is always true due to limited range of data type
// [-Wtype-limits]"
assert((unsigned)size <= SIZE_MAX);
#pragma GCC diagnostic warning "-Wtype-limits"
return (size_t) size;
}
Run Code Online (Sandbox Code Playgroud)
不同的编译器使用各种机制来抑制警告.我正在寻找便携式解决方案.
上述解决方案不可移植,gcc不幸的是这种方法有副作用:-Wtype-limits现在在此代码之后启用了警告,可能已启用也可能未启用.不知道如何恢复-Wtype-limits设置.
安装Rails后,根据这篇文章Ubuntu,Ruby,RVM,Rails和You.
在使用时scaffold我看到一些奇怪的警告.
我按照下面的步骤:
nazar@lelyak-desktop:~/Documents/rails? rails new blog
nazar@lelyak-desktop:~/Documents/rails/blog? cd blog
nazar@lelyak-desktop:~/Documents/rails/blog? rails generate scaffold post title:string body:text
/home/nazar/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/nazar in PATH, mode 040777
/home/nazar/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/nazar in PATH, mode 040777
/home/nazar/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.6.2/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/nazar in PATH, mode 040777
/home/nazar/.rvm/gems/ruby-2.1.0/gems/spring-1.1.2/lib/spring/application.rb:164: warning: Insecure world writable dir /home/nazar in PATH, mode 040777
Run Code Online (Sandbox Code Playgroud)
我想知道,如果我理解正确rails使用SqlLite默认情况下?怎么把在blog/db它没有创建任何sqlite3文件?
这里有问题吗?
我的代码/标记如下Index.cshtml:
<p>
@Html.ActionLink("Create New", "Create")
@using (Html.BeginForm("Index", "Clients", FormMethod.Get))
{
<p>
Title: @Html.TextBox("search") <br />
<input type="submit" value="Search" />
</p>
}
</p>
Run Code Online (Sandbox Code Playgroud)
Visual Studio 2013警告我,最后一行(</p>)没有开始标记.我在文档中没有任何其他<p>或</p>标签.这是怎么回事?
完整的警告信息:End tag is missing matching start tag.
当我运行以下haskell代码并启用警告
module Main where
main :: IO()
main = interact (unlines.strout.calc.extinps.words)
--calculates factorial
factorial :: Integral a=> a->a
factorial n = product [1..n]
--Extracts numbers from the input
extinps ::(Read b)=>[String]->[b]
extinps x=map read x
--Calculates the factorial
calc :: (Integral b) => [b] -> [b]
calc x= map factorial x
--Converts the result to a string
strout::(Show b)=>[b]->[[Char]]
strout x=[show a|a<-x]
Run Code Online (Sandbox Code Playgroud)
警告后我收到警告:
factout.hs:3:26: Warning:
Defaulting the following constraint(s) to type `Integer'
(Show b0) arising from a use of `strout' …Run Code Online (Sandbox Code Playgroud)