Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

local path to remote path

Status
Not open for further replies.

samyII

Programmer
Mar 22, 2005
14
IN
hi,
my application reads a file by using <input type=file> tag. in other words i get the local path of the file to be read. now the problem is that when i run this app on a network due to local address the server doesnot find the file.
how can i change the local path to remote path, or do i have to send this file to the server for processing. please help.
 
An input of type "file" uploads the file to the server, provided the enctype attribute is set to "multipart/form-data" and the method attribute is set to "post".

If this is a web application, you're going to get information from the $_FILES superglobal array, but the path on the browser-local filesystem will not be preserved.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thanks sleipnir214. i was using get method, and it was causing the trouble. by the way i tried to access $_FILES but it was empty. can u please tell me why?
 
Are you running a version of PHP that is version 4.1.0 or newer?
Does your form tag contain both the enctype and method attributes?

Something like:

<form entype="multipart/form-data" method="post" action="yoururl.php">

How are you checking the content of $_FILES?


All of these particulars, by the way, are available in the PHP online manual:

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
As I understand your question, you are trying to get a file path that works both on the server and on your local development system, correct?

If so, what I've found that seems to work is to use

getenv("DOCUMENT_ROOT");

for the first part of your path (the part that's different between your local set up and your live one) and from there, contatonate the absolute path to the actual folder where the files are.

For example:

$ServerPath = getenv("DOCUMENT_ROOT");

$ServerPath . "/files/images/" . $FileName;

Don
contact@pc-homepage.com
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top