/    Sign up×
Community /Pin to ProfileBookmark

Here is the code, for some reason, it isn’t outputting the text in the echo. What it is doing is displaying the first file upload page, but when it goes to actually upload (this file), nothing is displayed. It is supposed to display a “Now Loading…” graphic.

any help?

[code=php]<?php
include”db.php”;
session_start();
if($_SESSION[‘logged’] != 1){
header(“Location: login.php”);
}
echo’
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
<title>TzFiles – Free Ultimate File Hosting</title>
</head>
<body>
<div class=”container”>
<div class=”header”>’;
include”header.php”;
echo’
</div>
<div class=”content”>
<div class=”clear10″>
&nbsp;
</div>
<div style=”text-align:center”><img alt=”Loading…” src=”/images/loading_animated3.gif”></div>
</div>
<div class=”footer”>’;
include”footer.php”;
echo’
</div>
</div>
</body>
</html>’;
ob_flush();
flush();
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality){
$details = getimagesize(“$imageDirectory/$imageName”) or die(‘<div class=”container”>
<div class=”content”>
Please only upload images.
</div>
</div>’);
$type = preg_replace(‘@^.+(?<=/)(.+)$@’, ‘$1’, $details[‘mime’]);
eval(‘$srcImg = imagecreatefrom’.$type.'(“$imageDirectory/$imageName”);’);
$thumbHeight = $details[1] * ($thumbWidth / $details[0]);
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $details[0], $details[1]);
eval(‘image’.$type.'($thumbImg, “$thumbDirectory/$imageName”‘.(($type==’jpeg’)?’, $quality’:”).’);’);
imagedestroy($srcImg);
imagedestroy($thumbImg);
}
foreach ($_FILES[“file”][“error”] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$sql_size1 = mysql_query(“SELECT SUM(size) FROM files WHERE owner_id='{$_SESSION[‘id’]}'”);
$sum = mysql_fetch_array($sql_size1);
$tmp_name = $_FILES[“file”][“tmp_name”][$key];
$name = $_FILES[“file”][“name”][$key];
$name = strtolower($name);
$file = getext($name);
$image = ‘sessions/’.$_SESSION[user].’/’.$row[file_name];
$size = GetImageSize($tmp_name);
$width = $size[0];
$height = $size[1];
$filesize = filesize($tmp_name);
$max = $filesize+$sum[‘SUM(size)’];
if($max>$space_amount){
continue;
//$_SESSION[‘exceed_space’] = ‘<span class=”redtxt”><b>Sorry, but you can’t upload all of the choosen files</b></span>’;
}
$time = time();
#1 equals overwrite
if($_POST[‘write’] == ‘1’ && file_exists(“users/$_SESSION[user]/”.strtolower($name))){
if(in_array($file,$img_types)){
move_uploaded_file($tmp_name, “users/$_SESSION[user]/”.strtolower($name));
if($width < 120){
createThumbnail(“users/$_SESSION[user]”, strtolower($name), “users/$_SESSION[user]/thumbs”, $width, 80);
mysql_query(“UPDATE files SET size=’$filesize’ WHERE file_name='”.strtolower($name).”‘ AND owner_id='{$_SESSION[‘id’]}'”)or die(mysql_error());
}else{
createThumbnail(“users/$_SESSION[user]”, strtolower($name), “users/$_SESSION[user]/thumbs”, 120, 80);
mysql_query(“UPDATE files SET size=’$filesize’ WHERE file_name='”.strtolower($name).”‘ AND owner_id='{$_SESSION[‘id’]}'”)or die(mysql_error());
}
}else{
move_uploaded_file($tmp_name, “users/$_SESSION[user]/”.strtolower($name));
if(getext($name) == ‘.php’){
$movedfile = “users/$_SESSION[user]/”.strtolower($name);
chmod($movedfile,0666);
}
mysql_query(“UPDATE files SET size=’$filesize’ WHERE file_name='”.strtolower($name).”‘ AND owner_id='{$_SESSION[‘id’]}'”)or die(mysql_error());
}
}
#2 equals rename new file
elseif($_POST[‘write’] == ‘2’ && file_exists(“users/$_SESSION[user]/”.strtolower($name))){
$new_name = $time.$name;
if(in_array($file,$img_types)){
move_uploaded_file($tmp_name, “users/$_SESSION[user]/”.strtolower($new_name));
if($width < 120){
createThumbnail(“users/$_SESSION[user]”, strtolower($new_name), “users/$_SESSION[user]/thumbs”, $width, 80);
}else{
createThumbnail(“users/$_SESSION[user]”, strtolower($new_name), “users/$_SESSION[user]/thumbs”, 120, 80);
}
}else{
move_uploaded_file($tmp_name, “users/$_SESSION[user]/”.strtolower($name));
if(getext($name) == ‘.php’){
$movedfile = “users/$_SESSION[user]/”.strtolower($name);
chmod($movedfile,0666);
}
}
mysql_query(“INSERT INTO files(`file_name`, `ext`, `size`, `owner_id`, `date`) VALUES (‘”.strtolower($new_name).”‘, ‘”.getext($new_name).”‘, ‘$filesize’, ‘$_SESSION[id]’, ‘$time’)”)or die(mysql_error());
}else{
if(in_array($file,$img_types)){
move_uploaded_file($tmp_name, “users/$_SESSION[user]/”.strtolower($name));
if($width < 120){
createThumbnail(“users/$_SESSION[user]”, strtolower($name), “users/$_SESSION[user]/thumbs”, $width, 80);
}else{
createThumbnail(“users/$_SESSION[user]”, strtolower($name), “users/$_SESSION[user]/thumbs”, 120, 80);
}
}else{
move_uploaded_file($tmp_name, “users/$_SESSION[user]/”.strtolower($name));
if(getext($name) == ‘.php’){
$movedfile = “users/$_SESSION[user]/”.strtolower($name);
chmod($movedfile,0666);
}
}
mysql_query(“INSERT INTO files(`file_name`, `ext`, `size`, `owner_id`, `date`) VALUES (‘”.strtolower($name).”‘, ‘”.getext($name).”‘, ‘$filesize’, ‘$_SESSION[id]’, ‘$time’)”)or die(mysql_error());
}
}
}
header(“Location: user.php”);
?> [/code]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 15.2007 — Before you can [b]ob_flush()[/b], you have to turn ON the output buffering with [b]ob_start()[/b] and I couldn't find it in the code you posted.
Copy linkTweet thisAlerts:
@The_Little_GuyauthorJan 15.2007 — Oops, I must have accidentally removed it, well here it is, it still doesn't work.

[code=php]
<?php
include"db.php";
session_start();
if($_SESSION['logged'] != 1){
header("Location: login.php");
}
ob_start();
echo'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>TzFiles - Free Ultimate File Hosting</title>
</head>
<body>
<div class="container">
<div class="header">';
include"header.php";
echo'
</div>
<div class="content">
<div class="clear10">
&nbsp;
</div>
<div style="text-align:center"><img alt="Loading..." src="/images/loading_animated3.gif"></div>
</div>
<div class="footer">';
include"footer.php";
echo'
</div>
</div>
</body>
</html>';
ob_flush();
flush();
function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality){
$details = getimagesize("$imageDirectory/$imageName") or die('<div class="container">
<div class="content">
Please only upload images.
</div>
</div>');
$type = preg_replace('@^.+(?<=/)(.+)$@', '$1', $details['mime']);
eval('$srcImg = imagecreatefrom'.$type.'("$imageDirectory/$imageName");');
$thumbHeight = $details[1] * ($thumbWidth / $details[0]);
$thumbImg = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($thumbImg, $srcImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $details[0], $details[1]);
eval('image'.$type.'($thumbImg, "$thumbDirectory/$imageName"'.(($type=='jpeg')?', $quality':'').');');
imagedestroy($srcImg);
imagedestroy($thumbImg);
}
foreach ($_FILES["file"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$sql_size1 = mysql_query("SELECT SUM(size) FROM files WHERE owner_id='{$_SESSION['id']}'");
$sum = mysql_fetch_array($sql_size1);
$tmp_name = $_FILES["file"]["tmp_name"][$key];
$name = $_FILES["file"]["name"][$key];
$name = strtolower($name);
$file = getext($name);
$image = 'sessions/'.$_SESSION[user].'/'.$row[file_name];
$size = GetImageSize($tmp_name);
$width = $size[0];
$height = $size[1];
$filesize = filesize($tmp_name);
$max = $filesize+$sum['SUM(size)'];
if($max>$space_amount){
continue;
//$_SESSION['exceed_space'] = '<span class="redtxt"><b>Sorry, but you can't upload all of the choosen files</b></span>';
}
$time = time();
#1 equals overwrite
if($_POST['write'] == '1' && file_exists("users/$_SESSION[user]/".strtolower($name))){
if(in_array($file,$img_types)){
move_uploaded_file($tmp_name, "users/$_SESSION[user]/".strtolower($name));
if($width < 120){
createThumbnail("users/$_SESSION[user]", strtolower($name), "users/$_SESSION[user]/thumbs", $width, 80);
mysql_query("UPDATE files SET size='$filesize' WHERE file_name='".strtolower($name)."' AND owner_id='{$_SESSION['id']}'")or die(mysql_error());
}else{
createThumbnail("users/$_SESSION[user]", strtolower($name), "users/$_SESSION[user]/thumbs", 120, 80);
mysql_query("UPDATE files SET size='$filesize' WHERE file_name='".strtolower($name)."' AND owner_id='{$_SESSION['id']}'")or die(mysql_error());
}
}else{
move_uploaded_file($tmp_name, "users/$_SESSION[user]/".strtolower($name));
if(getext($name) == '.php'){
$movedfile = "users/$_SESSION[user]/".strtolower($name);
chmod($movedfile,0666);
}
mysql_query("UPDATE files SET size='$filesize' WHERE file_name='".strtolower($name)."' AND owner_id='{$_SESSION['id']}'")or die(mysql_error());
}
}
#2 equals rename new file
elseif($_POST['write'] == '2' && file_exists("users/$_SESSION[user]/".strtolower($name))){
$new_name = $time.$name;
if(in_array($file,$img_types)){
move_uploaded_file($tmp_name, "users/$_SESSION[user]/".strtolower($new_name));
if($width < 120){
createThumbnail("users/$_SESSION[user]", strtolower($new_name), "users/$_SESSION[user]/thumbs", $width, 80);
}else{
createThumbnail("users/$_SESSION[user]", strtolower($new_name), "users/$_SESSION[user]/thumbs", 120, 80);
}
}else{
move_uploaded_file($tmp_name, "users/$_SESSION[user]/".strtolower($name));
if(getext($name) == '.php'){
$movedfile = "users/$_SESSION[user]/".strtolower($name);
chmod($movedfile,0666);
}
}
mysql_query("INSERT INTO files(file_name, ext, size, owner_id, date) VALUES ('".strtolower($new_name)."', '".getext($new_name)."', '$filesize', '$_SESSION[id]', '$time')")or die(mysql_error());
}else{
if(in_array($file,$img_types)){
move_uploaded_file($tmp_name, "users/$_SESSION[user]/".strtolower($name));
if($width < 120){
createThumbnail("users/$_SESSION[user]", strtolower($name), "users/$_SESSION[user]/thumbs", $width, 80);
}else{
createThumbnail("users/$_SESSION[user]", strtolower($name), "users/$_SESSION[user]/thumbs", 120, 80);
}
}else{
move_uploaded_file($tmp_name, "users/$_SESSION[user]/".strtolower($name));
if(getext($name) == '.php'){
$movedfile = "users/$_SESSION[user]/".strtolower($name);
chmod($movedfile,0666);
}
}
mysql_query("INSERT INTO files(file_name, ext, size, owner_id, date) VALUES ('".strtolower($name)."', '".getext($name)."', '$filesize', '$_SESSION[id]', '$time')")or die(mysql_error());
}
}
}
header("Location: user.php");
?> [/code]
Copy linkTweet thisAlerts:
@NightShift58Jan 15.2007 — See: http://us2.php.net/manual/en/function.flush.php

You may have a PHP configuration issue. Please read through the above to see if there are any peculiarites which may apply to your case.
Copy linkTweet thisAlerts:
@The_Little_GuyauthorJan 15.2007 — I put this in an .htaccess file:

[B]<IfModule mod_gzip.c>

mod_gzip_on no

</IfModule>[/B]


It doesn't do anything

other than that I have no clue
Copy linkTweet thisAlerts:
@The_Little_GuyauthorJan 15.2007 — scrap that idea, I just found out that it is disabled completely, and I found this out from their wiki:

PHP functions flush(), ob_flush(), and ob_implicit_flush() will have no apparent effect on DreamHost. For performance reasons on a DreamHost shared host, output is buffered at a higher level than PHP (mod_gzip) and so these commands do not have any visible effect. If you need unbuffered output, you must contact Tech Support to request mod_gzip be disabled for your site.[/QUOTE]
×

Success!

Help @The_Little_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...