首頁  >  文章  >  後端開發  >  php使用file_get_contents和file_put_contents 如何实现保存文件 文件名不变

php使用file_get_contents和file_put_contents 如何实现保存文件 文件名不变

WBOY
WBOY原創
2016-06-13 12:26:581296瀏覽

php使用file_get_contents和file_put_contents 怎么实现保存文件 文件名不变
php使用file_get_contents和file_put_contents 怎么实现保存文件时 保存的文件名与上传过来时的文件一样 即上传1.jpg 保存的就是1.jpg怎么实现
------解决思路----------------------
用$content = file_get_contents($filename)获取到内容,file_put_contents($filename, $content)不就可以吗
------解决思路----------------------

<br />$url = 'http://www.xxx.com/1.jpg';<br />$file = basename($url);<br />$data = file_get_contents($url);<br />file_put_contents($file, $data, true);<br />

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn