ok that is what I am after. So I make lets say (upload.php) then upload it to the webserver home dir (/home/rob/)"; Then the listings.txt file upload it to the same place and create a cron job to execute the php script file.? Right?
This is the upload.php script I would use:
<?php
//Check to see if the form was submited and the file was uploaded
if($POST['submit'] && $sql_file != 'none'){
//File Path and File Name
$fileName = listings.txt';
$path = "/home/rob/file.txt";
$path = $SERVER['DOCUMENT_ROOT']."/test/admin/".$fileName;
//copy the uploaded file to the server
$tempName = $HTTP_POST_FILES['sql_file']['tmp_name'];
move_uploaded_file($tempName,$path);
//Create MySQL Class Instance
$MySQL = new MySQL;
//Delete records in the database
$MySQL->query_mysql("DELETE FROM MK_LISTINGS");
//Open and Read File
$handle = fopen($path, "r");
while (!feof($handle)) {
//Read in each line of the file and put it into buffer
$buffer = fgets($handle, 4096);
//Create MySQL Insert Query
$result = "INSERT INTO MK_LISTINGS VALUES (\"\",$buffer)";
//Check to see if the buffer is not empty, if not insert the record
if($buffer != ''){
$MySQL->query_mysql($result);
}
}
fclose($handle);
//Delete the file on the server
@unlink($path);
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if($_POST['submit']){
if($sql_file != 'none')
echo '<hr width="50%"><p align="center">Database was successfully updated!</p><hr width="50%">';
else
echo '<hr width="50%"><p align="center">Error: There was no file uploaded!</p><hr width="50%">';
}
echo "<p align=\"center\">\n";
echo "Please select a file you would like to upload.<br><br>";
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\" enctype=\"multipart/form-data\">\n";
echo "<input style=\"height=25\" type=\"file\" name=\"sql_file\" value=\"\">\n";
echo "<input style=\"height=25\" type=\"submit\" name=\"submit\" value=\"Upload File\">\n";
echo "</form>\n";
echo "</p>\n";
?>
</body>
</html>