Jump to content

[SOLVED] files wont open


ma5ect

Recommended Posts

I have a download script which holds files which have been uploaded by the users.. the files are shown on this page but once i try to open them, nothin happens...any1 help

 

script

 

<?php require_once('Connections/mysql_connect.php'); ?>

<?php

if(isset($_GET['name']))

{

 

$name    = $_GET['name'];

$query  = "SELECT type, size, content FROM uploadfiles WHERE name = '$name'";

$result  = mysql_query($query) or die('Error, query failed');

list($name, $type, $size, $content) = mysql_fetch_array($result);

 

header("Content-Disposition: attachment; filename=$name");

header("Content-length: $size");

header("Content-type: $type");

echo $content;

 

exit;

}

mysql_select_db($database_mysql_connect, $mysql_connect);

$query_Recordset1 = "SELECT * FROM uploadfiles";

$Recordset1 = mysql_query($query_Recordset1, $mysql_connect) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

 

mysql_free_result($Recordset1);

 

?>

<html>

<head>

<title>Download File From MySQL</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body>

<?

 

$query  = "SELECT name FROM uploadfiles";

$result = mysql_query($query) or die('Error, query failed');

if(mysql_num_rows($result) == 0)

{

echo "Database is empty <br>";

}

else

{

while(list($name) = mysql_fetch_array($result))

{

?>

<a href="download.php?id=<?=$id;?>"><?=$name;?></a> <br>

<?

}

}

 

?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/112751-solved-files-wont-open/
Share on other sites

now the files are displayed all in a line and are not recognised file types.. when i click open the following error appears:

 

Warning: Header may not contain more than a single header, new line detected. in C:\xampp\htdocs\download.php on line 12

 

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\download.php:12) in C:\xampp\htdocs\download.php on line 13

 

Not sure if this will fix it, but check what you are doing with

list($name, $type, $size, $content) = mysql_fetch_array($result);

 

You are trying to set $name first, but you did not select name on your sql statement.

Just remove $name from the list() parameters.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.