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 ";

Comments

Post a Comment

Popular posts from this blog

jasper reports - How to center align barcode using jasperreports and barcode4j -

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -