Jump to content

Recommended Posts

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
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";?>
</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";?>
</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]
Link to comment
https://forums.phpfreaks.com/topic/34192-ob_start/
Share on other sites

I just noticed:

You're echoing this:
<?include"header.php";?>
</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";?>

You should echo everything but the includes.


Change your echo html to this:
[code]<?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>';?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/34192-ob_start/#findComment-160918
Share on other sites

scrap that idea, I just found out that it is disabled completely, and I found this out from their wiki:

[QUOTE]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]
Link to comment
https://forums.phpfreaks.com/topic/34192-ob_start/#findComment-160964
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.