简体   繁体   中英

How to copy files to external hard drive in php

I'm using a php script to download large files from a server and then do some processing. How can I copy them to my external hard drive after I'm done processing them?

Update: I can use copy() . How do I reference my external drive? It shows up as Iomega_HDD in finder. But

copy('test.jpg, 'Iomega_HDD/test2.jpg') 

doesn't work.

Update2:

copy('test.jpg, '/Volumes/Iomega_HDD/test2.jpg') 

Did trick ...

为什么不使用php copy()命令呢?

Just use any file function and specify the full path to the correct drive, assuming you have write access to that drive. Here is an example using file_put_contents .

In windows:

file_put_contents( 'E:\somefile.txt', $data);

In Linux:

file_put_contents( '/media/{yourdeviceID}/somefile.txt', $data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM