Hi,
Ideally I want to have a file upload form and then the contents of the file uploaded put into a text box on the same page.
At the moment I have two pages, upload.html and uploader.php
upload.html contains the form and the user selects which file to upload……uploader.php then shows the contents of the file.
I want this to happen all on the one page is this possible and how would I do this?
The code I currently have is:
upload.html:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “
<html xmlns=”
<head>
<meta content=”text/html; charset=utf-8″ http-equiv=”Content-Type” />
<title>Untitled 2</title>
</head>
<body>
<?php
$target_path = “uploads/”;
$target_path = $target_path . basename( $_FILES[‘uploadedfile’][‘name’]);
$filename = basename( $
if(move_uploaded_file($_FILES[‘uploadedfile’][‘tmp_name’], $target_path)) {
// echo “The file ” . $filename . ” has been uploaded”;
} else{
echo “There was an error uploading the file, please try again!”;
}
$myFile = “uploads/” . $filename;
$fh = fopen($myFile, ‘r’);
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;?>
</body>
</html>
uploader.php:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “
<html xmlns=”
<head>
<meta content=”text/html; charset=utf-8″ http-equiv=”Content-Type” />
<title>Untitled 2</title>
</head>
<body>
<?php
$target_path = “uploads/”;
$target_path = $target_path . basename( $_FILES[‘uploadedfile’][‘name’]);
$filename = basename( $
if(move_uploaded_file($_FILES[‘uploadedfile’][‘tmp_name’], $target_path)) {
// echo “The file ” . $filename . ” has been uploaded”;
} else{
echo “There was an error uploading the file, please try again!”;
}
$myFile = “uploads/” . $filename;
$fh = fopen($myFile, ‘r’);
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;?>
</body>
</html>
Is this possible and how would I do it?