scottybwoy Posted February 2, 2007 Share Posted February 2, 2007 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 Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 2, 2007 Share Posted February 2, 2007 Sorry, doesn't make any sense. ??? Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted February 2, 2007 Author Share Posted February 2, 2007 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. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 2, 2007 Share Posted February 2, 2007 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. Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted February 2, 2007 Author Share Posted February 2, 2007 Thats a great start, thanks, I have now a search box, but if I do a print_r($_FILES); It is a blank array? What is meant to be in there? Quote Link to comment Share on other sites More sharing options...
rantsh Posted February 2, 2007 Share Posted February 2, 2007 the data from your uploaded file... if it's blank it means there's no file uploaded Quote Link to comment Share on other sites More sharing options...
simcoweb Posted February 2, 2007 Share Posted February 2, 2007 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; Quote Link to comment Share on other sites More sharing options...
scottybwoy Posted February 6, 2007 Author Share Posted February 6, 2007 Thanks for all your help, It worked just by using $_REQUEST or whatever you use to post the data, did not work using $_FILE but may do if you have a unique form for that relevant section. Thanks again peeps Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.