Jump to content

Problem Uploading File


scanbird
 Share

Recommended Posts

I have already written about this but I am still running into ... inaction from PHP.I need to ask the user to point a file locally, then I read the file and populate a database on the server from it.Here is the form declaration :<form name="formDAT" method="post" action="file_choice_handler.php?FileType=DAT" enctype="plain/text"> with "multipart/form-data" loops foreverHere is the input field :<input type="hidden" name="fileDATname" id="fileDATname"/><input type="file" name="fileDAT" size="50" id="fileDAT" onchange="java script:document.formDAT.fileDATname.value= document.formDAT.fileDAT.value"/> java script:document ... was added at the suggestion of one of you folks to make sure to pass all the complete path reference in the valueHere is the code at the beginning of 'file_choice_handler.php' pertinent to the testing : $DatFileName=$_FILES['formDAT']['name']; echo 'DatFileName : '.$DatFileName.'<br/>'; $DatFileName2=$_GET['fileDATname']; echo 'DatFileName2 : '.$DatFileName2.'<br/>';here is an alternate I have also tried for the first line : $DatFileName=$_GET['fileDAT'];The results are as follow : In DEV-PHP2 environment, which uses it own server, DatFileName is Filename.ext and DatFileName2 ends up looking like : C:\\Directory\\Sub-Directory\\Filename.ext and everything works fineIn all other ways I have tried : XAMPP Apache 2 server locally and ISP distant server DatFileName and DatFileName2 are the same : Filename.extSo the question is WHY ? and also How can I keep track of the path of the file as $_FILES['']['name'] doesn't seem to do it?And just for the purpose of trying to learn something more : Why if I say method="post" in the code do I get the answers via $_GET ($_POST are empty)!Thanks

Link to comment
Share on other sites

It doesn't make sense to populate get and not post, it should be populating post with that data. You do need multipart/form-data as the enctype, it won't upload the file otherwise.Browsers handle file inputs differently. I'm not sure of any way to get the full path in all browsers, it's just not something that's available. Some people consider that a privacy issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...