關於thinkphp下file_put_contents執行不了問題

來源:互聯網
上載者:User
$img=file_get_contents("http://img04.taobaocdn.com/bao/uploaded/i4/T1NlTRFLtcXXXXXXXX_!!0-item_pic.jpg");$ret=@file_put_contents('1.jpg',$img);

這段代碼放在thinkphp的模組代碼下執行不了這是怎麼回事啊 file_put_contents這個函數沒作用這是為什麼呢?


回複討論(解決方案)

檢查一下檔案夾的許可權。

按照你目前的寫法是寫入目前的目錄,檢測下目前的目錄是不是沒有讀寫權限;建議儲存到需要儲存的可讀寫的目錄中比較好。

1、確定執行到了嗎?
2、如果執行到了,有不有許可權?

你是怎麼調用?是寫的action方法?

去掉“@”號看看有麼有報錯。
print_r(error_get_last());

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.