LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 11-29-2010, 02:50 AM   #1
vijaysince89
LQ Newbie
 
Registered: Oct 2010
Posts: 18

Rep: Reputation: 0
Question Getting full path while using the input type is file in HTML


Hello everyone,
Below is my code.
<html>
<body>

<form action="compress.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />

<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

How to get the full path? I've used $_FILE["file"]["name"] but it returns only the file name. not its full directory.
Any Idea?

Regards,
Vijay

Last edited by vijaysince89; 11-29-2010 at 02:55 AM.
 
Old 11-29-2010, 04:03 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
If you want to get full path of the file on the client system it is impossible. Maybe with Adobe Flash.
 
Old 11-29-2010, 08:59 AM   #3
vijaysince89
LQ Newbie
 
Registered: Oct 2010
Posts: 18

Original Poster
Rep: Reputation: 0
Then why they have unnecessarily provided this option to us? If we can not get the full path it is not possible to open the file that we have included in that directory, right? if I try to open the file using fopen() it says that the file is not found in the default directory. If we place the file in the default directory it works. Then How can we upload a file in other directory which is not default directory? Please help me. I think you can understand what I'm trying to say.
 
Old 11-29-2010, 05:06 PM   #4
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
There are two paths on two different computers. First is on the client machine. On the server you can't known his local system path, web browser doesn't send this information to the server, for security purposes.

The second is path to file on server after web browser uploaded it. You should use function move_uploaded_file() with directory, where you want this file to be stored. Before that the file is temporary saved in directory specified in php config file under directive "upload_tmp_dir".

More info in PHP manual.

Last edited by eSelix; 11-29-2010 at 05:09 PM.
 
Old 11-29-2010, 06:08 PM   #5
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
There's a previous thread that might interest you.
http://www.linuxquestions.org/questi...in-php-321798/
 
Old 11-29-2010, 08:33 PM   #6
vijaysince89
LQ Newbie
 
Registered: Oct 2010
Posts: 18

Original Poster
Rep: Reputation: 0
Thank you both.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the full path of a file in C? Basel Programming 3 10-30-2010 10:52 PM
php5 problem with uploads from IE using html form input type file miedward Programming 3 04-06-2010 01:24 PM
Get full path of a file get_to_know Programming 1 08-03-2009 12:34 AM
full path of a file ttilt Linux - General 1 11-08-2005 06:02 PM
htmldoc - a different input from an html file - cubax Linux - General 1 05-15-2005 11:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 05:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration