954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

File directory with <input type='file'...>

Hi,

I have a routine which reads a file using type='file'. I would like to be able to update the file and save it in the same location it came from, which would be in the C:\ directory. However, I cannot see how to get hold of the path associated with my file. Can anyone help with this?

Thanks, Dave.

davewylie
Newbie Poster
16 posts since Jan 2008
Reputation Points: 10
Solved Threads: 1
 

Hi,

I have a routine which reads a file using type='file'. I would like to be able to update the file and save it in the same location it came from, which would be in the C:\ directory. However, I cannot see how to get hold of the path associated with my file. Can anyone help with this?

Thanks, Dave.

can you plz explain the problem more clearly..........with some snipet that you applied

nil_gh_80
Junior Poster in Training
64 posts since Aug 2007
Reputation Points: 8
Solved Threads: 2
 

Hi,

I have a routine which reads a file using type='file'. I would like to be able to update the file and save it in the same location it came from, which would be in the C:\ directory. However, I cannot see how to get hold of the path associated with my file. Can anyone help with this?

Thanks, Dave.


i think one solution for this is:
you just get the path you have to update in database and also in folder....
just use unlink to delete the file in that folder...
then simply use update query to update the path and use your regular code to insert the file in your folder...
hope this will helps you...

Shanti C
Posting Virtuoso
1,642 posts since Jul 2008
Reputation Points: 137
Solved Threads: 162
 

Shanti,

I don't understand your suggestion. Let me add more detail to the problem.
I am writing some code to automate sending emails for annual subscriptions to members of my running club. I do not use a database, as there is personal data which I do not want to reside on the server. The club secretary holds records on an excel spreadsheet, and saves as an .xml type file. This is then entered on a form into the program, as follows:

<form enctype="multipart/form-data" 
  action="member-list.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
  <table width="600">
  <tr>
  <td>Names file:</td>
  <td><input type="file" name="memList" /></td>
  <td><input type="submit" value="Upload" /></td>
  </tr>
  </table>
</form>

Note that I do not know where the .xml file resides, it is somewhere on his c:\ drive.
I then access the file via a DOM:

$dom = DOMDocument::load( $_FILES['memList']['tmp_name'] );

and change a date field in one of the nodes in the dom. I am able to successfully save the updated file as follows, but ONLY if I know where the .xml file resides:

$dom->save('c:\\filepath\Members.xml');

As I have said, I do not know the filepath, and wish to know how to obtain that information.
The code

$_FILES['memList']['name'];

only gives me the file name (in this case Members.xml) but not the filepath.

Dave.

davewylie
Newbie Poster
16 posts since Jan 2008
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You