照《PHP与MySQL程序设计(第3版)》那本书(15.2.5 一个简单的示例,252页),写了一段利用表单上传文件的简单代码,如下:<form action="uploadmanager.php" enctype="multipart/form-data" method="post">
Last Name:<br /> <input type="text" name="name" value="" /><br />
Class Notes:<br /><input type="file" name="classnotes" value="" /><br />
<p><input type="submit" name="submit" value="Submit Notes" /></p>
</form><?php 
/* Set a constant */
define ("FILEREPOSITORY", "c:/Temp/");

/* Make sure that the file was POSTed */
if (is_uploaded_file($_FILES['classnotes']['tmp_name'])) {

/* Was the file a PDF? */
if($_FILES['classnotes']['type'] != "application/pdf") {
echo "<p>Class notes must be uploaded in PDF format.</p>";
} else {
/* move uploaded file to final destination */
$name = $_POST['name'];
$result = move_uploaded_file($_FILES['classnotes']['tmp_name'],
FILEREPOSITORY."/$name.pdf");

if ($result == 1) echo "<p>File successfully uploaded.</p>";
else echo "<p>There was a problem uploading the file.</p>";
} #endIF
} #endIF
?>在表单里填入姓名和文件,点击按钮提交,结果弹出提示窗口:
php-cgi.exe - 应用程序错误,
-0x00f2fac0指令引用的"0x68676972"内存,该内存不能为"read"。
要终止程序,请单击“确定”。
要调试程序,请单击“取消”。点击“确定”后,网页上显示:
FastCGI Error
The FastCGI Handler was unable to process the request. 
--------------------------------------------------------------------------------Error Details:•The FastCGI process exited unexpectedly
•Error Number: -1073741819 (0xc0000005).
•Error Description: Unknown Error
HTTP Error 500 - Server Error.
Internet Information Services (IIS)我用的环境是IIS5 + FastCGI + PHP5.3,浏览器是ie8,PHP.ini中关于文件上传的设置是:
file_uploads = On
max_execution_time =300
memory_limit = 128M
upload_max_filesize = 2M
upload_tmp_dir="C:\WINDOWS\Temp"
post_max_size = 8M
max_file_uploads = 20请问是什么原因导致出错,怎么解决?

解决方案 »

  1.   

    我上传的文件很小,281KB的PDF文件
      

  2.   

    现在通用的环境是:lamp文件上传很简单,感觉你走了弯路。
      

  3.   

    是的,lamp是最好的组合,小弟也是知道的呀,只是在弯路探索一下,有时候也很有意思。有能给个解释的吗?让别人在Windows7里(也是IIS+PHP)试了一下,我这个代码是可以执行的。
      

  4.   

    自已也感觉用打了补丁的IIS运行PHP也不像话,就换了Apache做Web服务,搞定结论:别用IIS5.0,那东西太恐怖了