0

所以,我有这个代码,但没有工作

<?
foreach($itemlist as $item) {
    $imagepic = $item['mainpictureurl'];
    for($k=0;$k<count($imagepic);$k++){
            echo $imagepic++;
            echo "<br>";
            $isok=copy($imagepic[$k] , $_SERVER . dirname(__FILE__).'/test/item_'.($k+1).'.jpg');
            if($isok==true){
                echo' success!';  
            }else{
                echo ' Fail';  
            }
        }
    }
?>

我不断收到此错误

Warning: copy(h) [function.copy]: failed to open stream: No such file or directory in /home/decultur/public_html/shop/templatescustom/main/itemlist.html on line 111
Fail

我错过了什么,请告诉我

4

2 回答 2

0

$_SERVER是一个数组,所以你的路径是从路径开始的Array。您需要找到您正在寻找的实际值并为此使用正确的索引。

于 2012-06-05T14:41:27.330 回答
0

您将$_SERVER数组作为一个整体使用,这将导致(转换为字符串后)在Array. 您应该使用$_SERVER['your_var'] 查看手册:http ://www.php.net/manual/en/reserved.variables.server.php

于 2012-06-05T14:41:43.137 回答