I'm trying to have a user upload a text file to the server and have the text inside that .txt file inserted into a string so it can be entered into a database.
The upload, I assume, works fine. It's retrieving the data from the uploaded file that I am having problems with. Here is the code that the upload script is posting to:
<?
$filename = $HTTP_POST_FILES["userfile"]["tmp_name"];
$filesize = $HTTP_POST_FILES["userfile"]["size"];
$name = $HTTP_POST_FILES["userfile"]["name"];
$fd = fopen("$filename", "r") or die ("Cannot open file for reading!");
$contents = fread ($fd, filesize ($filename)) or die ("Cannot read file!");
fclose ($fd);
echo $contents;
?>
I'm working with IIS and Advanced Server 2000 here. It tells me that the file is posted to C:\WINNT\TEMP\php(insert incremental number here)\myfile.txt
The fopen does not return an error, but when it gets to the fread it cannot read the file. No idea why.
Help! Deadlines are closing in!