Forum Moderators: coopster
<?php
// Edit this
// Where does the file get uploaded to?
// put in the full path to directory with a trailing (/ on the end) slash
$File_path = "upload/";
if ($_POST['Submit']) {
// Form has been submitted.
// Set the names into shorter variables.
$File_name = $_FILES['TheFile']['name'];
$File = $_FILES['TheFile']['tmp_name'];
if (!(file_exists("$File_path$File_name"))) {
// The file doesnt exist, attempt to copy to the folder.
$FileCopyWorked = @copy("$File", "$File_path$File_name");
}
if ($FileCopyWorked) {
echo "File has been uploaded successfully; another?<br />";
}
else
{
echo "File has not been uploaded successfully; Please make sure the directory exists, try again?<br />";
}
}
// Gets current file name.
$Current_Page = basename($_SERVER['PHP_SELF']);
// Displays the form
echo "<form method="post" action="$Current_Page" enctype="multipart/form-data">
<input name="TheFile" type="file" style="width:100%;"><br />
<input type="submit" name="Submit" style="width:100%;"><br />
</form>";
?>
echo "<form method="post" action="$Current_Page" enctype="multipart/form-data">
<input name="TheFile" type="file" style="width:100%;"><br />
<input type="submit" name="Submit" style="width:100%;"><br />
</form>";
Should be:
echo "<form method=\"post\" action=\"$Current_Page\" enctype=\"multipart/form-data\">
<input name=\"TheFile\" type=\"file\" style=\"width:100%;\"><br />
<input type=\"submit\" name=\"Submit\" style=\"width:100%;\"><br />
</form>";
HTH