How to upload image from other server to another? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to upload image from other server to another?

I would like to add an upload of files to my server where I will be uploading my files from other server within the same network. But I dont know what is the right code for PHP.

16th Jun 2017, 12:48 PM
Dani Manalang
Dani Manalang - avatar
1 Answer
0
you can use the $_FILES[] superglobal in combination with the move_uploaded_file() function. But beware, do not use this on public servers as it will probably be insecure if you're not an experienced developer. When not properly secured, it allows people to upload arbitrary (php) files to your server and execute them. In the worst case taking over your complete server and database. If you want to do it securely you must manually write the file name/extension and not trust the user input, besides the file itself. Always use a whitelist of allowed extensions. (Do not trust MIME types) If you want to upload it from a php file to another server, you can use the php cURL library to POST to the other server. I hope this information helps.
19th Jun 2017, 11:47 AM
Rab1t
Rab1t - avatar