佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 951|回复: 4

PHP 新手问题

[复制链接]
发表于 16-12-2006 09:04 AM | 显示全部楼层 |阅读模式

  1. <?
  2. //Generate.php
  3. $srcurl = "content.txt";
  4. $tempfilename = "tempfile.php";
  5. $targetname = "index.php";

  6. @unlink($tempfilename);
  7. $file = fopen($srcurl,"r") or die("Could not find ".$srcurl);
  8. $content = fread($file,filesize($file));
  9. fclose($file);
  10. $file2 = fopen($tempfilename,"w");
  11. copy($file2,$targetname);
  12. fclose($file2);
  13. unlink($tempfilename);

  14. ?>
复制代码


OUTPUT:

Warning: filesize() [function.filesize]: Stat failed for Resource id #2 (errno=2 - No such file or directory) in /home/kenyi/public_html/0125/php/Semi Dynamic page/Generate.php on line 8

Warning: fread() [function.fread]: Length parameter must be greater than 0. in /home/kenyi/public_html/0125/php/Semi Dynamic page/Generate.php on line 8

Warning: fopen(tempfile.php) [function.fopen]: failed to open stream: Permission denied in /home/kenyi/public_html/0125/php/Semi Dynamic page/Generate.php on line 10

Warning: fclose(): supplied argument is not a valid stream resource in /home/kenyi/public_html/0125/php/Semi Dynamic page/Generate.php on line 12

Warning: unlink(tempfile.php) [function.unlink]: No such file or directory in /home/kenyi/public_html/0125/php/Semi Dynamic page/Generate.php on line 13


做么会是 "No such file or directory"的?
其他 file 都放在同一个 directory.
回复

使用道具 举报


ADVERTISEMENT

发表于 16-12-2006 01:00 PM | 显示全部楼层
原帖由 kenyi 于 16-12-2006 09:04 AM 发表

<?
//Generate.php
$srcurl = "content.txt";
$tempfilename = "tempfile.php";
$targetname = "index.php";

@unlink($tempfilename);
$file = fopen($srcurl," ...

式下用full path name
回复

使用道具 举报

发表于 18-12-2006 12:16 AM | 显示全部楼层
很明显,你要开的挡案不存在。-_-|||
回复

使用道具 举报

发表于 23-12-2006 05:38 PM | 显示全部楼层
PHP is "filename-case sensitive" language; and it will NOT get e.g. CONTENT.php as content.php, try to check whether the file exist, file wrong name, or not exist at all.
回复

使用道具 举报

发表于 23-12-2006 08:12 PM | 显示全部楼层
第一,filesize的argument type是String filename而不是resource;
第二,之前filesize的return是0,fread不允许.
第三,你需要directory的write permission.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 14-11-2024 04:52 AM , Processed in 0.106786 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表