PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPHP Development
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.


Tutorials
| Forums

Download to Enter
| Contest Rules

DOWNLOAD INTEL® GPA FOR FREE

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 21st, 2003, 01:26 PM
swreinha swreinha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 swreinha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Getting the remote file path from <input type="file">

I'm using a form to upload a file to save in a mySQL database, however I need to store the original file path on the clients (the user uploading the file) computer.
The file path is shown in the field that selects the file, I just need to post it or save it in a session somehow.

Any thoughts?

Thanks
Steve.

Reply With Quote
  #2  
Old March 21st, 2003, 02:20 PM
alan alan is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 211 alan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
$HTTP_POST_FILES[’userfile’][’name’] - should contain the original file name of the file being uploaded so you should be able to simply assign that to a session var or a cookie or where you intend to save it.

<input type="file" name="myfile ">

session_start();
session_register("userfile");
$userfile = $HTTP_POST_FILES[’myfile ’][’name’];


Alan

Reply With Quote
  #3  
Old March 21st, 2003, 03:36 PM
swreinha swreinha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 swreinha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the tip Alan

That will get me the name of the file being passed, but what I need is the entire path that the file held when it was uploaded.

ex 'C:/WINDOWS/temp/something.txt'

I want to add the 'C:/WINDOWS/temp/' to a session variable or at least have it posted to the next page.

I need to store the path in order to restore that file to the right location.

Reply With Quote
  #4  
Old March 21st, 2003, 03:50 PM
Dingle Dingle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 452 Dingle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 12 sec
Reputation Power: 12
I very much doubt this is possible, it wouldn't be good for a browser to reveal information about a users file system.

Reply With Quote
  #5  
Old March 21st, 2003, 03:53 PM
alan alan is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 211 alan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
$HTTP_POST_FILES[’myfile ’][’name’] will actually contain the "entire" file name including the path.

Alan

Reply With Quote
  #6  
Old March 21st, 2003, 03:59 PM
Dingle Dingle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 452 Dingle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 12 sec
Reputation Power: 12
uh, no it won't

Reply With Quote
  #7  
Old March 21st, 2003, 04:14 PM
swreinha swreinha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 swreinha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
When I use either $HTTP_POST_FILES['filename']['name'] or $_FILES['filename']['name'] I only get the name of the file and not the path.
I'm using PHP version 4.3.0 with registered_globals = off;

Here's my code :

This is the form that inputs the file

<form method="POST" action="upload.php" ENCTYPE="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="hidden" name="action" value="upload">
<table border="1">
<tr>
<td>File: </td>
<td><input type="file" name="binFile" default="none"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Upload"></td>
</tr>
</table>
</form>

It POSTs to a file with this code.

print_r($HTTP_POST_FILES);
print $HTTP_POST_FILES['binFile']['name'];

If I enter a file called thefile.txt

Array ( [binFile] => Array ( [name] => thefile.txt [type] => text/plain [tmp_name] => D:\Program Files\PHP\uploadtemp\php3D8.tmp [error] => 0 [size] => 41 ) ) Stuff in the file

only the path of the temp file on the server is listed

Reply With Quote
  #8  
Old March 21st, 2003, 04:14 PM
alan alan is offline
PHPer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 211 alan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
My appologies... I assumed after seeing:

"The original name or path of the file on the sender’s system ."

in the PHP manual when describing the use of $HTTP_POST_FILES[’userfile’][’name’] that "name or path" implied that if a path was used, a path would be present in the resulting var.



Alan

Reply With Quote
  #9  
Old March 21st, 2003, 04:18 PM
swreinha swreinha is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 swreinha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Alright, thanks very much Alan.

I'll have to look for another way around this.

Steve

Reply With Quote
  #10  
Old March 21st, 2003, 04:24 PM
Dingle Dingle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 452 Dingle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 12 sec
Reputation Power: 12
a thought, it may or may not work...

in your form add a hidden field for the remote file path, and update it when the file control changes.

Code:

<form name="myform">
<input type="hidden" name="remote_file_path" value="">
<input type="file" name="upfile" onchange="document.myform.remote_file_path.value=this.value;">

Reply With Quote
  #11  
Old March 21st, 2003, 04:31 PM
Dingle Dingle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 452 Dingle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 12 sec
Reputation Power: 12
this seems to work:

Code:
<?php
	echo $_REQUEST['remote_file_path'];

?>

<br>
<form name="myform">
<input type="hidden" name="remote_file_path" value="">
<input type="file" name="upfile" onchange="">

<input type="button" value="submit"
	onclick="document.myform.remote_file_path.value=document.myform.upfile.value;document.myform.submit();">

</form>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Getting the remote file path from <input type="file">


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap