Download file thru website from another server - php

I have a website on one server and lots of storage on another server.
When user access the page I show file names fetched from server with lots of storage.
Is it possible to somehow proxy a download so that when user want to get a file it will be send thru a server with website without downloading it to
the site with webpage?
What is best solution to this problem?

Related

How can i hide the download link of another server?

I sell video in my website. users must pay to have access to files (to download or stream them online)
problem: the video files are not on my main server! i store them on another server.(special server for download. i don't want to use the bandwidth of my main server) i don't want to provide the users with the direct link. (not to let them share the links with others...). how can i let them to download the files or stream the videos without giving them the direct links?
points:
- I can not have database(mysql) in my download server.
- i don't want to use the bandwidth of my main site. just checking payments and controlling user accounts.
- streaming is not so important. but i have to let them download the files.
- i have seen in woo commerce plugin(wordpress) which creates temporary download links even for remote server. i checked solutions for temp download link but all works for the same server not remote one....
The easiest way I think this could happen is:
The public server must be able to establish an SSH (preferably) connection to the other server with appropriate permissions.
Upon successful request, create a random symlink pointing to the original file.
Store the symlink filename in a database, and save the user's IP as well - or some other unique identifier (or md5'd IP + User Agent - it's up to you).
If the request is valid (matches the record in the database), let him download the file. Otherwise redirect him to an error page.
Set up a cron to delete symlinks older than X hours.

Opening a word document on clients PC, through a PHP application

I am developing a web application in PHP as a replacement of Microsoft Access based application for a company.
In old access application in their database they were storing a link to a word document, which further links to other documents. Now in access form they are showing that link, when click on that link they can open the word document from a common folder in a network PC and make any changes the that file (pretty easy for user).
Is there any way to do the same through the web-based application?
What if I just move the common folder in my www directory?
In that case they can open the file easily, but if they have to make any change they have to download the file on their PC, and the changes will be done to their local file not in the file that is on server. So they need to move file to server back or ask network admin for moving the file back to the server
What if I keep common folder in a network PC it self and try to access it form there?
Just by clicking I can’t open a file form client’s or any other network PC. For this when click on the link I have to open & read file through PHP on web server. Using any document to PDF converter, I have to convert the file format and then open it in browser. Here the problem are,
Still I can’t make changes in file and
I have to fix about the format that I might need to convert in PDF.
I am not sure how the other documents that are linked to the main document will work.
There's two ways of doing this: (a) let the user download it from your web application, either statically (stored on the web server) or dynamically (processed in PHP or even built in real-time).
Or, (b) use a file link to a known location on the user's disk, such as file://C:/mydoc.doc.
Addendum - if you want to write to the file in your web app, but also have the user open the same copy, use (b) rather than (a). This presumes that the location of the file is available through a local or network path.

Upload images from my server to password protected site

I'm in the process of building a site that will help to organize my business. But I'm at a roadblock. Our site is coded in PHP and MySQL and as it currently stands, our contractors can upload images to our site, our site relabels the pictures and associates them with a work order (for ability to search later, if needed), then stores the images in our database.
However, what I want to do is have the images uploaded to their respective work order on our supplier's site. I have contacted our supplier and they will not allow us to access their server directly through the POST commands. So I'm curious if there is a way to still have our images uploaded from our site to our supplier's site. Their site is password protected. On their site, I find the work order associated to the work order and manually upload the images, but I'd like to find a way to do this automatically. The work order numbers between their site and ours are the same. Any ideas?
New Info
The comment I left below just states that I have to actually manually click the upload button, choose which photos to upload, then click "upload" to have the images uploaded. FTP is not allowed either.
If by "manually" you mean all by www after logging in, you can use CURL to simulate login session to their website (access login page to obtain session cookie, then post login data with that session cookie, and then with authorized session cookie you can GET/POST whatever you want from their website as authorized user). Use Firebug to track what requests are made and what data are passed from/to their website.
Since using CURL can be painfull (it's syntax is far from user friendly) you can try grab and extract Zend_Http from Zend Framework so you will have very easy syntax and it even work without CURL if you haven't it on your servers.
if they will grant you ftp access you can programatically transfer the images to them that way
or if they have some sort of api exposing methods to upload images
By "manually upload", you mean via FTP? You can do it with PHP. Here is the documentation.
For security reasons, I suggest you create an FTP user on your client's server which only has access to the images directory, and connect trough that account.

access data on apache server using xampp

i am writing an iphone application, which basically uploads and downloads Images to/from a server. in order to test my code i installed xampp and everything works fine now. if i upload an image the server creates a folder named with the UDID-number of the device
(via the http-method POST a php script is called).
but if i enter the directory of such a folder and the name of the image in the browser i can see it in the browser.
i am a newby on this topic and have no idea if there are better possibilities. my questions are: should i use databases where i save the images or is it just fine to create folders via a php script and save the images into these folders? can i hide all the datastructure, such that you cannot access it via a browser but only with the iphone application? (the application should only be able to download pictures randomly). thx
If you do not want an image serverable by apache, you need to store it outside the webroot. So if your webroot is C:\xampp\htdocs, you could store the images in a folder structure under C:\xampp\images
Your iphone app would have to do a little more work then to pull a random one and send it to the user.

Download file using FTP and PHP

I would like to start a upload and download website for huge files (up to 1gb). I thought that it would be better to download the files using FTP (with PHP), because this protocol is especially used for these types of transfers.
The cliënt gets an email, including a download link to download the file (like yousendit.com). When they click on the link a download box appears. My problem is that I don't know how to show a download box using ftp and php. I have read that it isn't possible to immediately download a file by PHP, using FTP. Is this correct?
Do I have to create a temporary files on the server to let the client download the file? If yes, is this also a good solution for huge files?
What do you advice me to give the clients the possibility to download these huge files?
Thanks for your reply!
You can generate unique address based on session_id (create this folder on runtime and move huge file there) and redirect user to this link
For example, you have file huge.tgz
1. Send you client link http://***/user/john/file/huge.tgz
2. Ask user for auth in this page if they lost session
3. get session id
4. create on your server folder with name equals session id and move huge.tgz here
5. redirect user to unique ftp link ftp://***/17oe5kf8iYmpt66bjs89hcuo83/huge.tgz
You should disallow list files and directories on ftp server
Can't you send them an FTP link ? Why do you need PHP?
ftp://ftp12.freebsd.org/pub/FreeBSD/ls-lR.gz
You probably want to use PHP to handle everything but the file transfer. Once you have done all the checks you want you can redirect the browser to the file specifying the protocol as ftp. though you won't be able to have a progression bar in your site, the browser/ftp app will probably display one.

Categories