Hi,
A while ago I wrote a script to upload nfo/txt files to my server directory in a tody organized place, storing links to the files in the dbase rather than using BLOB fields.
I have lost this code, but have re-written it to the best of my recollection. I now want to store html files on my server (same manner - just link to the files which I can then retrieve through another script), but I am getting a strange error.
My initial 'add record' file is just a plain html file with a form and elements (named as per table/columns in my sql dbase) and the form action is to 'upload.php3' - which contains the following:
<?php
if ($page == "text/html") {
MYSQL_CONNECT("localhost","user","pass");
mysql_select_db("dbase_name");
$sql = "INSERT INTO games (title,developer,publisher,platform,genre,cart_size,origin,reviewer,score,list,File_HTML)
VALUES ('$title','$developer','$publisher','$platform','$genre','$cart_size','$origin','$reviewer','$score','$list','$File_HTML')";
$result = mysql_query($sql);
exec("cp $page /path/to/uploaded/file/$File_HTML");
echo "Title: $title<br>\n";
echo "Developer: $developer<br>\n";
echo "Publisher: $publisher<br>\n";
echo "Genre: $genre<br>\n";
echo "Cart Size: $cart_size<br>\n";
echo "Origin: $origin<br>\n";
echo "Score: $score<br>\n";
echo "A-Z: $list<br>\n";
echo "<br>\n";
MYSQL_CLOSE();
} else {
// else show the form to submit new data:
echo "Error! Incorrect File Type";
}
?>
This basically puts the data from the previous html page into the dbase table, into the relevant columns. However! I am not able to do this. If I REMOVE the top if statement and ending else statement, the adding to the database works fine (except no link to a file is stored in 'File_HTML') and I get a file uploaded to my server named as some random crap (e.g. fe3T4feWWG - the temp name it must be given on uploading). WITH the statements left intact, I get the error message thrown by the else EVERY time - I don't know why since I am uploading a .html file which is of text/html MIME type.
I know last time I did not use any temporary files or anything like that.
I did fix this before (I thought it was to do with the CHMOD of my web directory, but not to be so, since it is at 777 already) and now it's annoying me a great deal I can't fix it this time!
Any help before I go mad?
Cheers