I have 2 diffrent problems with this Code,
I am on winXP runing IIS 4 with PHP and MSSQL. the database connection works fine but the query is giving me greif.
I am trying to stream a file to it's new home inside the MSSQL database. But I keep getting errors when it's trying to read the file.
- Warning: fopen(ander.php): failed to open stream: Permission denied in c:\inetpub\wwwroot\sparktrial\db_connect.php on line 88
This happens when I try to upload a file from my documents folder.
2.
Warning: feof(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\sparktrial\db_connect.php on line 90
Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\sparktrial\db_connect.php on line 92
I get both of these errors when I attach any file from other than my C:\ Drive.
Relating Code Below:
function fileput($file){
$data = "";
$file = stripslashes($file);
echo $file;
//get file
$fp = fopen("$file", "rb") ||die("cannot open $file");
if($fp) echo "$file was opened.";
while(!feof($fp))
{
$data .= fread($fp, 1024);
}
fclose($fp);
$data = addslashes($data);
$data = addcslashes($data, "\0");
//connect to database
if(!($dblink = mssql_connect("localhost", "user", "pass")))
{
print("Unable to connect to database!");
exit();
}
mssql_select_db("DB", $dblink);
$Query = "INSERT INTO files VALUES(" .
"'$file', " .
"'$data')";
if(!mssql_query($Query, $dblink))
{
print("Insert failed!");
}
}