|
- <?
- //Generate.php
- $srcurl = "content.txt";
- $tempfilename = "tempfile.php";
- $targetname = "index.php";
- @unlink($tempfilename);
- $file = fopen($srcurl,"r") or die("Could not find ".$srcurl);
- $content = fread($file,filesize($file));
- fclose($file);
- $file2 = fopen($tempfilename,"w");
- copy($file2,$targetname);
- fclose($file2);
- unlink($tempfilename);
- ?>
复制代码
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. |
|
|
|
|
|
|
|
发表于 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. |
|
|
|
|
|
|
| |
本周最热论坛帖子
|