how to upload file from a link? [PHP] - php

I have a php project and it needs to upload a file to the server from a [blob] link... I have searched and all I found was to upload a file with tag and it is not my case.

You can use simple file_put_content and file_put_contents
for example
file_put_contents("file.extension", ("link"));

Related

Upload file content to dropbox

I want to upload file that I am generating in my app. It looks like I can upload file if I will provide path to the file, or url where the file is, but I have only content of the file. Is there a way I can upload that content dropbox ? I am using third party php sdk
I solved this by creating temporary file that will be uploaded and then deleted.

How to delete a file after using move_uploaded_file()

Ok, I first uploaded a file using move_uploaded_file(). I then used Dropbox to grab that file and used Dropbox SDK to upload the file to my Dropbox account. I now don't need that file in my File Directory. I only need that file in my Dropbox account. How do I now delete this file with PHP?
My guess would be something like this: delete_file($movie_tmp, $movie_destination);
Thanks!
It's just unlink('page.html');

Rename and saving remote image to server

i'm looking for a simple way to download remote images to my sever, rename and save image name to database.
I know how to download the file easily to my sever
copy('http://example.com/file.jpeg', '/tmp/file.jpeg');
But how to i rename the image while downloading or after download?
I would really appropriate if anyone can tell me a simple way to do this using php
In copy function just change file name:
copy('http://example.com/file.jpeg', '/tmp/any_file_name.jpeg');
I think this should do the Job
rename("/tmp/tmp_file.jpg", "/home/user/login/docs/my_file.jpg");
you have to do this after you downloaded it
or just change the file name while you dwonload it e.g.
copy('http://example.com/file.jpeg', '/tmp/some_name.jpg');

How to save uploaded file in qq file uploader using php?

I am using https://github.com/Widen/fine-uploader uploader script on my website. I am searching for solution to save uploaded file in qq file uploader using php server side script.
I tried to request file using $_FILES['qqfile']['tmp_name'] but didn't works. Can anyone tell me php example to request and save file in qq file uploader?
Have a look at the php example in the server folder of the file-upload github project.
goto this url
http://code.google.com/p/php-axiom/source/browse/trunk/libraries/uploader/qqUploadedFileXhr.class.php?spec=svn41&r=41
or search about qqUploadedFileXhr
Incase of those who may bump into this thread, here's a perfect example, helped me alot
http://wsnippets.com/fancy-profile-image-upload-crop-jquery-ajax-php/

Downloading pdf files from a website and changing the filename after download

I am trying to download some files. I have written a php script that can gather all of the address of the pdf files I need to download into a array but the file names on that server are odd. How does one go about downloading pdf files with php?
you can try (if I understand your question correctly)
file_put_contents('/your/file/name.pdf',
file_get_contents('http://www.example.com/oddFile.pdf'))
Check out the file or file_get_contents functions. It can take URLs as well as local filenames.
http://www.php.net/manual/en/function.file.php
http://www.php.net/manual/en/function.file-get-contents.php

Categories