麻烦Mozilla和我的PHP下载计数器 [英] Trouble with Mozilla and my PHP download counter

查看:56
本文介绍了麻烦Mozilla和我的PHP下载计数器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


RedHat9上的PHP 4.2.2


生成文件位置动态,因此URL保存在数据库中。


我有一个简单的PHP脚本,粘贴下面。 IE用户很好,但是Mozilla

用户实际上在屏幕上看到了文件内容,就像垃圾一样,而不是用另存为来表示
。对话框。


下载的文件有.msi扩展名(二进制文件)。


谁能看到我做错了什么?我需要发送不同的/额外的

标题吗?


非常感谢!


Jim


========================================== =


<?php

//检索参数

$ FileID = isset($ _ REQUEST [" ID" ])? $ _REQUEST [" ID"]: - 1;


//连接到数据库

$ link = mysql_connect(" localhost",root" ,xxxxxx或死(不能连接:
connect:。mysql_error());

mysql_select_db(" Downloads")或die(" ;无法选择下载数据库");


//这是一个有效的下载吗?

$ query =" SELECT * FROM DownloadItems WHERE FileID =' '$ FileID''" ;;

$ result = mysql_query($ query)或die(" Query failed:" .mysql_error());

$ num_rows = mysql_num_rows($ result);


if($ num_rows!= 1)

die(Invalid Download);


//获取行

$ row = mysql_fetch_array($ result,MYSQL_ASSOC);


//获取URL

$ FileURL = $ row [" FileURL"];


//释放数据库连接

mysql_free_result($ result);


//重定向

标题(Content-Type:application / force-download);

标题(位置:$ FileURL);

?>


Jim Willsher


主页 http://www.jimwillsher.co.uk

Hi all,

PHP 4.2.2 on RedHat9

I have some files on my website for people to download, and I want to
generate the file location "on the fly", so the URL is held in a database.

I have a simple PHP script, pasted below. IE users are fine, but Mozilla
users actually see the file contents on screen, as garbage, instead of
being presented with the "save as" dialog.

The files for download have the .msi extension (binaries).

Can anyone see what I''m doing wrong? Do I need to send different/additional
headers?

Many thanks!

Jim

===========================================

<?php
// Retrieve the parameters
$FileID = isset($_REQUEST["ID"]) ? $_REQUEST["ID"] : -1;

// Connect to the database
$link = mysql_connect("localhost", root", "xxxxxx") or die("Could not
connect : " . mysql_error());
mysql_select_db("Downloads") or die("Could not select Downloads database");

// Is this a valid download?
$query = "SELECT * FROM DownloadItems WHERE FileID=''$FileID''";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
$num_rows = mysql_num_rows($result);

if ($num_rows != 1)
die("Invalid Download");

// Obtain the row
$row = mysql_fetch_array($result, MYSQL_ASSOC);

// Obtain the URL
$FileURL = $row["FileURL"];

// Release the database connection
mysql_free_result($result);

// Redirect
header("Content-Type: application/force-download");
header("Location: $FileURL");
?>

Jim Willsher

Homepages at http://www.jimwillsher.co.uk

推荐答案

FileID = isset (
FileID = isset(


_REQUEST [" ID"])?
_REQUEST["ID"]) ?


_REQUEST [" ID"]: - 1;

//连接数据库
_REQUEST["ID"] : -1;

// Connect to the database


这篇关于麻烦Mozilla和我的PHP下载计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆