PHP remote file download with custom name set -
I have this script which makes me a remote file on my server
The problem is, If I want to rename the file, I have to manually FTP the server and change the name of the file. Is there any way to name the file before downloading?
& lt ;? Php if ($ _ POST) {// url $ url = $ _POST ['url']; // Add time to the current filename $ name = basename ($ url); List ($ txt, $ ext) = explosion (".", $ Name); $ Name = $ txt.time (); $ Name = $ name "." $ Ext // Here is the actual code for getting the file from the URL and to save it to the upload folder, get the file from the URL using // file_get_contents and file_put_contents $ upload = file_put_contents ("uploads / $ name", file_get_contents ( $ Url)); // Check the success ($ Upload) echo "success: & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt; Anybody can help, I will be very happy.
I have to manually rename the file, this is the problem, can I specify a name before, in any way or in another, am I uploading?
Thanks in advance
The path of the new file is file_put_contents "upload / {$ new_name}" where $ new_name = "wanted_file_name." $ Ext ";
php प्रोग्रामिंग उदाहरण स्क्रिप्ट
ReplyDeleteलिंक को क्लिक करने योग्य हाइपरलिंक उदाहरण कोड में परिवर्तित करें