图像 - 上传不响应,无法访问$ _FILES [英] Image - Upload not responding, no access to $_FILES
问题描述
这是我的文件上传脚本,我收到以下错误
注意:未定义的索引:fupload在C :\Users\Tuskar\Desktop\Projekt\htdocs\Project IT-Space\Profile\edit_profile_parse.php第8行
但是根据那里不应该出错,因为我确定了索引。似乎我没有访问$ _FILES数组,因为在我得到这个错误之前,我已经得到其他类似的错误,或者程序完全通过if并直接转到else(文件未选择)
我知道脚本是原始的,几乎没有安全性,但我只是希望它在我添加其他功能,如最大文件大小或文件限制之前首先工作:(
这是我正在使用的代码。
上传图片
< ; form action =edit_profile_parse.phpmethod =getenctype =multipart / form-data>
< input type =hiddenname =MAX_FILE_SIZEvalue =999999999>< ; / input>
< input type =filename =fupload>< / input>
< input type =submitname =submitvalue =Upload >< / input>
< / form>
处理表单
if(isset($ _GET ['submit']))
/ pre>
{
if (isset($ _ FILES ['fupl oad']))
{
echoname:$ _ FILES ['fupload'] ['name']。< br> ;
echosize:。$ _ FILES ['fupload'] ['sizw']。 <峰; br> ;
echotype:。$ _ FILES ['fupload'] ['type']。 <峰; br>
if($ _FILES ['fupload'] ['type'] ==image / gif)
{
$ source = $ _FILES ['fupload' [$ tmp_name'];
$ target =images /$ _ FILES ['fupload'] ['name'];
move_uploaded_file($ source,$ target)or die( .mysql_error());
$ size = getImageSize($ target);
$ imgstr =< img src = \'$ target。'\ &;
echo $ imgstr;
}
else
{
echo上传文件时出现问题;
}
}
else
{
echo没有文件选择! ;
}
}
else
{
echo按钮未点击;
}
解决方案您应该使用表单方式POST而不是get。
< form action =edit_profile_parse.phpmethod =postenctype =multipart / form-data>
/ pre>
Here is my file-upload script, and i am getting the following error
Notice: Undefined index: fupload in C:\Users\Tuskar\Desktop\Projekt\htdocs\Project IT-Space\Profile\edit_profile_parse.php on line 8
But according there should not error, because i identified the index. It seems i don't have access to the $_FILES array, because before i got this error ive been getting other similar errors or the programm completely passes the if and goes directly to the else (file not chosen)
I know the script is primitive and includes almost no security, but i just want it to work first before i add other features like max file size or file restriction ... :(
Here is the code i am using.
Upload Picture <form action="edit_profile_parse.php" method="get" enctype="multipart/form-data" > <input type="hidden" name="MAX_FILE_SIZE" value="999999999"> </input> <input type="file" name="fupload"> </input> <input type="submit" name="submit" value="Upload"> </input> </form>
Here is the php that handles the form
if (isset( $_GET['submit'] )) { if (isset($_FILES['fupload'] )) { echo "name: ".$_FILES['fupload']['name']." <br> "; echo "size: ".$_FILES['fupload']['sizw']." <br> "; echo "type: ".$_FILES['fupload']['type']." <br> "; if ($_FILES['fupload']['type'] == "image/gif") { $source = $_FILES['fupload']['tmp_name']; $target = "images/" .$_FILES['fupload']['name']; move_uploaded_file($source, $target) or die ("Error: " .mysql_error()); $size = getImageSize($target); $imgstr = "<img src=\" '".$target."' \">"; echo $imgstr; } else { echo "Problem uploading the file ... "; } } else { echo "No file chosen !! "; } } else { echo "Button not clicked "; }
解决方案You should use form method to POST instead of get.
<form action="edit_profile_parse.php" method="post" enctype="multipart/form-data" >
这篇关于图像 - 上传不响应,无法访问$ _FILES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!