Jump to content

[SOLVED] Locate Files


scottybwoy

Recommended Posts

Hi All,

 

What would I use to bring up a file search box?

 

The best way to explain it is to pretend if you want to upload a file, but at the last step, don't.  Just get the location of the file to store in a database.  Does that make sense?

 

I'm using a button to trigger this from my html, just don't know how to implement it.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/36776-solved-locate-files/
Share on other sites

I'd like to click on a button, to bring up an explorer type search box like opening a file in pretty much most apps.  Then the user can locate the file, once located I only want to use the address, not open/upload the file.  Then I want to take the address and store it in the database.  Hope that clears it up.

Link to comment
https://forums.phpfreaks.com/topic/36776-solved-locate-files/#findComment-175426
Share on other sites

Ok, getting clearer :)

 

So, you want a popup window with a search/browse button so they can locate a file. But, you don't want the file uploaded. Just the location of it? So you can insert that location into a database? Not sure how that's going to work since the location may be on their hard drive.

 

In a <form> you create the 'Browse' button and field by designating the type as a "file":

 

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

 

On submit that automatically tells the form to upload the file selected which then starts a chain reaction of info about the file being placed into an array so you can further manipulate it. This includes the name of the file that can be stored in the database.

 

Now, one possibility may be in how your form is set up. This tag is required if you're looking to upload a file:

 

enctype="multipart/form-data"

 

Honestly I don't know what the form would do if the tag is missing. It might ignore the upload and just create a browse button that would fill a text field that you could use to provide a value to a variable in $_POST mode so you can place it into the database. Don't know, haven't tried, not sure, just a guess. Might just break, not work, etc. etc.  But, somehow you need to create a browse button/field that doesn't upload anything on submit except the entry.

Link to comment
https://forums.phpfreaks.com/topic/36776-solved-locate-files/#findComment-175436
Share on other sites

That's what I explained in the second post. The <input type="file"> creates an array containing a few info items about the file that are important in the upload process.

 

Your code is missing an ingredient for printing the info. Should be like this:

 

print_r($_FILES['upload_file'];  // or whatever you named the field

 

or,

 

$file_loc = $_FILES['upload_file'];

echo $file_loc;

 

 

Link to comment
https://forums.phpfreaks.com/topic/36776-solved-locate-files/#findComment-175504
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.