I want to upload this text file using the code given below and want to read the uploaded file when I hit submit button. I know there is a problem in this code that's why it is not working. pls help me to do that.
you need to process the file first and then read... something like this, but you need to check if the form has been submitted..
## define target directory for you the uploaded file
$file_directory = 'someDirectory';
if(isset($_POST['submit']) && ($_FILES["file"]["error"] > 0)){
## move the uploaded file to your specified location, if there is no problem on submit
move_uploaded_file($_FILES["file"]["tmp_name"], $file_directory .'/'. $_FILES["file"]["name"]);
}
else{
echo 'No file uploaded at this time';
}
## to read the file
## double check and make sure the file exist in file_directory, before opening it
if (file_exists($file_directory .'/' . $_FILES["file"]["name"])) {
## put your text file reader function Here..
}