Solved

Access file over network with username and password

Posted on 2014-03-03
8
532 Views
Last Modified: 2014-03-12
Is it possible to connect to a network file share over a network with a different username and password other than www-data.

I've got a ubuntu web server, but not much storage space, however on the same network I've got 4TB available but only network sharing with usernames and passwords.

I need to be able to read write to the share if possible as well. I can access via FTP if needed though.
0
Comment
Question by:tonelm54
  • 3
  • 2
  • 2
8 Comments
 

Author Comment

by:tonelm54
ID: 39901650
What Im hoping is a way of doing something similar to:-
	$data = file_get_contents('//username:password@server/myShare/myFolder/myFile.dat');
	
	echo $data;

Open in new window


So in real terms:-
	$data = file_get_contents('//tcross:64TTyr6@192.168.1.55/storage/myWebStore1/file0006.dat');
	
	echo $data;

Open in new window

0
 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39902990
Why do you want to connect via the webserver - why not mount the network share to the system as an admin at which point it will be available to your web server?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39903326
You might be able to do this with cURL.  Please set up the test data URL (a portion of the  SSCCE) and tell us what credentials you want us to use.  I'll be glad to make a test and show you the results.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 54

Expert Comment

by:Julian Hansen
ID: 39903770
You might be able to do this with cURL.
Only if there is a web service listening on the other side. I interpret the question as requiring file access to a file on a remote share - in which case cUrl is not viable.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39903874
@julianH: I'll wait for the author to post the credentials before I give up on any particular solution.  

I may be missing something of the economics in this question, since a gigabyte of storage can be purchased for the cost of a few sheets of toilet paper.  To me it would seem obvious and easy to just add storage to the web server.
0
 

Author Comment

by:tonelm54
ID: 39910685
Unfortunately I'm stuck with the host size, I cannot increase it. However I do have several TB on another server Im able to use. My thought is at the moment is to use FTP to copy the file into a temporary store on the host then serve it as needed.
0
 
LVL 54

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39911689
Is the other server only accessible via FTP or is it possible to mount the remote volume on your http server?

Do the contents of the files change?

If not then you might want to consider implementing a file caching solution - where the files that are requested the most frequently are cached on the server to boost performance - having to wait for an FTP connect and transfer could degrade overall performance of your site.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question