PDA

View Full Version : BioUpload - merge into site not working...



jackass
11-06-2008, 08:49 PM
Okay, I am adding the uploader to my actualy site, instead of a seperate link. The upload form works perfectly, but the actual upload script doesn't...

The site is http://biolabs.x10hosting.com/bioupload.html

Code;

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org (http://www.w3.org)">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Biolabs v1</title>

<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
/*<![CDATA[*/
li.c2 {list-style: none}
span.c1 {font-weight: bold;}
/*]]>*/
</style>
</head>
<body>
<div id="holder">
<div id="header">
<div id="logo2"><img src="images/newlogo.bmp" alt="logo"></div>
<br>
<div id="menu">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="scripts.html">Scripts</a></li>
<li><a href="vip.html">VIP</a></li>
<li><a href="uploader/uploadform.php">BioUpload</a></li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="sidebar"><span class="c1">Current Projects:</span><br>
BioUpload v2<br>
BioUpload VIP v1<br>
VIP System<br>
BioProxy v1<br>
BioConverter v1<br>
<br>
<span class="c1">Current Labs:</span><br>
BioUpload v1.5<br>
HxF Status Signature v1<br>
<br>
<span class="c1">Current Releases:</span><br>
BioUpload v1<br>
<br>
<span class="c1">Current VIP Releases:</span><br>
N/A<br>
<br>

<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401-blue"
alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
</p>

</div>
<div id="text">
<?
session_start();
$n=$_FILES['user_file']['name'];
$type=$_FILES['user_file']['type'];
$size=$_FILES['user_file']['size'];
$time=time();
$n=$time;
$path="uploads//". $n;


$uploaded = $_SESSION['firsttimeupload'];
if ($uploaded == "ok")
{
if ($size <1048576 && ereg("image", $type ))
{
move_uploaded_file($_FILES['user_file']['tmp_name'],
$path);

$root= "http://biolabs.x10hosting.com/uploads/";
$path2=$root . $n;
echo "<center>";
echo "<h3><span style='color: #000;'><center><b>Your Image Link Is: </h3><a href=$path2>$path2</a></b><center></span><br><br>";
echo "<br>";
echo "<img src=$path2 border='5'></img>";
echo "<center>";


$fp=fopen("links.text", "at");
fwrite($fp, $path2."\n");
fclose($fp);
session_destroy();
}
}
else
{
echo "<span style='color: #000;'><center><b>You can't upload the same image too many times per session!<br>Go back and choose another one!</b><center></span>";
}

////////////
if ($size>1048576)
{
echo "<span style='color: #000;'><center><b>ERROR<br>The image size is too big!</b><center></span>";
}
if (!ereg("image", $type) )
{
echo "<span style='color: #000;'><center><b>ERROR<br>The file is not image!</b><center></span>";
}
echo "";
?>
</div>
</div>
<div id="footer">
<div id="left_footer"><strong><strong>Copyright �2008 Biolabs.co.uk</strong></strong></div>
<div id="right_footer"><strong><strong>Site created by Jack Moore</strong></strong></div>
</div>
</div>
</body>
</html>

--ss--
11-06-2008, 08:51 PM
You may want to change the page extension to .php? :P

jackass
11-06-2008, 08:58 PM
You may want to change the page extension to .php? :P

Yeah, but it does this... :(


Warning: session_start() [function.session-start (http://biolabs.x10hosting.com/function.session-start)]: Cannot send session cache limiter - headers already sent (output started at /home/biolabs/public_html/bioupload2.php:13) in /home/biolabs/public_html/bioupload2.php on line 92

Agnostic Bear
11-06-2008, 09:03 PM
Yeah, but it does this... :(
Ugh, add to the very top of the page:
<?php
ob_start();
?>

add to the very bottom of the page:
<?php
ob_flush();
?>

Independent
12-06-2008, 07:36 AM
Ugh, add to the very top of the page:
<?php
ob_start();
?>

add to the very bottom of the page:
<?php
ob_flush();
?>
Just make footer files..

which contain ob_start and flush, tis' what I do with session_start.

edit: the session_start MUST be at the TOP of the page, not the top of the PHP code, so do this..



<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Biolabs v1</title>

<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
/*<![CDATA[*/
li.c2 {list-style: none}
span.c1 {font-weight: bold;}
/*]]>*/
</style>
</head>
<body>
<div id="holder">
<div id="header">
<div id="logo2"><img src="images/newlogo.bmp" alt="logo"></div>
<br>
<div id="menu">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="scripts.html">Scripts</a></li>
<li><a href="vip.html">VIP</a></li>
<li><a href="uploader/uploadform.php">BioUpload</a></li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="sidebar"><span class="c1">Current Projects:</span><br>
BioUpload v2<br>
BioUpload VIP v1<br>
VIP System<br>
BioProxy v1<br>
BioConverter v1<br>
<br>
<span class="c1">Current Labs:</span><br>
BioUpload v1.5<br>
HxF Status Signature v1<br>
<br>
<span class="c1">Current Releases:</span><br>
BioUpload v1<br>
<br>
<span class="c1">Current VIP Releases:</span><br>
N/A<br>
<br>

<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401-blue"
alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
</p>

</div>
<div id="text">
<?php
$n=$_FILES['user_file']['name'];
$type=$_FILES['user_file']['type'];
$size=$_FILES['user_file']['size'];
$time=time();
$n=$time;
$path="uploads//". $n;


$uploaded = $_SESSION['firsttimeupload'];
if ($uploaded == "ok")
{
if ($size <1048576 && ereg("image", $type ))
{
move_uploaded_file($_FILES['user_file']['tmp_name'],
$path);

$root= "http://biolabs.x10hosting.com/uploads/";
$path2=$root . $n;
echo "<center>";
echo "<h3><span style='color: #000;'><center><b>Your Image Link Is: </h3><a href=$path2>$path2</a></b><center></span><br><br>";
echo "<br>";
echo "<img src=$path2 border='5'></img>";
echo "<center>";


$fp=fopen("links.text", "at");
fwrite($fp, $path2."\n");
fclose($fp);
session_destroy();
}
}
else
{
echo "<span style='color: #000;'><center><b>You can't upload the same image too many times per session!<br>Go back and choose another one!</b><center></span>";
}

////////////
if ($size>1048576)
{
echo "<span style='color: #000;'><center><b>ERROR<br>The image size is too big!</b><center></span>";
}
if (!ereg("image", $type) )
{
echo "<span style='color: #000;'><center><b>ERROR<br>The file is not image!</b><center></span>";
}
echo "";
?>
</div>
</div>
<div id="footer">
<div id="left_footer"><strong><strong>Copyright �2008 Biolabs.co.uk</strong></strong></div>
<div id="right_footer"><strong><strong>Site created by Jack Moore</strong></strong></div>
</div>
</div>
</body>
</html>


Also I changed <? to <?php - as <? may intefear with XML Documents if you decide to add any on that page.

Dentafrice
12-06-2008, 11:59 AM
Why are you using sessions anyway, there is really no need to calculate a first time upload?

jackass
12-06-2008, 03:13 PM
Thanks, its fixed now anyway. :8


Why are you using sessions anyway, there is really no need to calculate a first time upload?

For spam reasons. :P

Dentafrice
12-06-2008, 03:16 PM
Ohh, there are easier ways to calculate that :P

jackass
12-06-2008, 03:18 PM
Ohh, there are easier ways to calculate that :P

Well it could search for duplicate filenames, but thats not always reliable...

Whats your method? :P

Dentafrice
12-06-2008, 03:20 PM
Well the session really isn't doing much is it, as it isn't setting anything? It is just checking to see if it is equal to "ok"

I would log them in a DB, like I do on TehUpload with the IP and the filename, and then check to see if there are any records of that filename, that ip, and that filesize that was uploaded.

if there is, I just display the link to the previous file, so you don't reupload files more then once.

jackass
12-06-2008, 03:37 PM
Well the session really isn't doing much is it, as it isn't setting anything? It is just checking to see if it is equal to "ok"

I would log them in a DB, like I do on TehUpload with the IP and the filename, and then check to see if there are any records of that filename, that ip, and that filesize that was uploaded.

if there is, I just display the link to the previous file, so you don't reupload files more then once.

Hmm clever. :P

I'm sorting out v1.5, and doing a clean up of test images. :)

Dentafrice
12-06-2008, 06:00 PM
A shell script could do that for you :P

jackass
13-06-2008, 03:41 PM
Argh, i've now come across a new problem.

I updated the upload script slightly (not the forum), and it has messed up - even though i didn't edit anything major!

It just says "You have uploaded too much per session blah blah blah" etc. no matter what you do!

Heres the code...


<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Biolabs v1</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
/*<![CDATA[*/
li.c2 {list-style: none}
span.c1 {font-weight: bold;}
/*]]>*/
</style>
</head>
<body>
<div id="holder">
<div id="header">
<div id="logo2"><img src="images/newlogo.bmp" alt="logo"></div>
<br>
<div id="menu">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="scripts.html">Scripts</a></li>
<li><a href="vip.html">VIP</a></li>
<li><a href="bioupload.php">BioUpload</a></li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="sidebar"><span class="c1">Current Projects:</span><br>
BioUpload v2<br>
BioUpload VIP v1<br>
VIP System<br>
BioProxy v1<br>
BioConverter v1<br>
<br>
<span class="c1">Current Labs:</span><br>
BioUpload v1.5<br>
HxF Status Signature v1<br>
<br>
<span class="c1">Current Releases:</span><br>
BioUpload v1<br>
<br>
<span class="c1">Current VIP Releases:</span><br>
N/A<br>
<br>

<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401-blue"
alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
</p>

</div>
<div id="text">
<?php
$n=$_FILES['user_file']['name'];
$type=$_FILES['user_file']['type'];
$size=$_FILES['user_file']['size'];
$time=time();
$n=$time;
$path="uploads//". $n;

$uploaded = $_SESSION['firsttimeupload'];
if ($uploaded == "ok")
{
if ($size <1048576 && ereg("image", $type ))
{
move_uploaded_file($_FILES['user_file']['tmp_name'],
$path);

$root= "http://biolabs.x10hosting.com/uploads/";
$path2=$root . $n;
echo "<center>";
echo "<h3><span style='color: #000;'><center><b>Your Image Link Is: </h3><a href=$path2>$path2</a></b><center></span>";
echo "<br>";
echo "<img src=$path2 border='5'></img>";
echo "<center>";


$fp=fopen("links.text", "at");
fwrite($fp, $path2."\n");
fclose($fp);
session_destroy();
}
}
else
{
echo "<span style='color: #000;'><center><b>You can't upload the same image too many times per session!<br>Go back and choose another one!</b><center></span>";
}

////////////
if ($size>1048576)
{
echo "<span style='color: #000;'><center><b>ERROR<br>The image size is too big!</b><center></span>";
}
if (!ereg("image", $type) )
{
echo "<span style='color: #000;'><center><b>ERROR<br>The file is not image!</b><center></span>";
}
echo "";
?>
</div>
</div>
<div id="footer">
<div id="left_footer"><strong><strong>Copyright �2008 Biolabs.co.uk</strong></strong></div>
<div id="right_footer"><strong><strong>Site created by Jack Moore</strong></strong></div>
</div>
</div>
</body>
</html>

Dentafrice
13-06-2008, 03:50 PM
You're not defining the session to be "ok"...

jackass
13-06-2008, 03:53 PM
You're not defining the session to be "ok"...

"if ($uploaded == "ok")"

And thats the session??

Jack!
13-06-2008, 03:57 PM
I got a probelm with the uploader i cliked upload ONCE and i get this

You can't upload the same image too many times per session!
Go back and choose another one!

jackass
13-06-2008, 03:58 PM
I got a probelm with the uploader i cliked upload ONCE and i get this

You can't upload the same image too many times per session!
Go back and choose another one!

Thats what were talking about now! :P

It seems to think that uploading an image is 'else', going straight to duplicate sessions... :(

Dentafrice
13-06-2008, 04:46 PM
But you never define that $uploaded is == okay? Right now the session is blank.. you never define it.

jackass
13-06-2008, 05:35 PM
But you never define that $uploaded is == okay? Right now the session is blank.. you never define it.

I don't get you? :(

Can you give me the fixed code please?

Heres the updated code...


<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Biolabs v1</title>


<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
/*<![CDATA[*/
li.c2 {list-style: none}
span.c1 {font-weight: bold;}
/*]]>*/
</style>
</head>
<body>
<div id="holder">
<div id="header">
<div id="logo2"><img src="images/newlogo.bmp" alt="logo"></div>
<br>
<div id="menu">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="scripts.html">Scripts</a></li>
<li><a href="vip.html">VIP</a></li>
<li><a href="bioupload.php">BioUpload</a></li>
<li><a href="about.html">About</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="sidebar"><span class="c1">Current Projects:</span><br>
BioUpload v2<br>
BioUpload VIP v1<br>
VIP System<br>
BioProxy v1<br>
BioConverter v1<br>
<br>
<span class="c1">Current Labs:</span><br>
BioUpload v1.5<br>
HxF Status Signature v1<br>
<br>
<span class="c1">Current Releases:</span><br>
BioUpload v1<br>
<br>
<span class="c1">Current VIP Releases:</span><br>
N/A<br>
<br>

<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401-blue"
alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
</p>

</div>
<div id="text">
<?php
$n=$_FILES['user_file']['name'];
$type=$_FILES['user_file']['type'];
$size=$_FILES['user_file']['size'];
$time=time();
$n=$time;
$path="uploads//". $n;

$uploaded = $_SESSION['firsttimeupload'];
if ($uploaded == "ok")
{
if ($size <1048576 && ereg("image", $type ))
{
move_uploaded_file($_FILES['user_file']['tmp_name'],
$path);

$root= "http://biolabs.x10hosting.com/uploads/";
$path2=$root . $n;
echo "<center>";
echo "<h3><span style='color: #000;'><center><b>Your Image Link Is: </h3><a href=$path2>$path2</a></b><center></span>";
echo "<br>";
echo "<img src=$path2 border='0'></img>";
echo "<center>";


$fp=fopen("links.text", "at");
fwrite($fp, $path2."\n");
fclose($fp);
session_destroy();
}
}
else
{
echo "<span style='color: #000;'><center><b>You can't upload the same image too many times per session!<br>Go back and choose another one!</b><center></span>";
}

////////////
if ($size>1048576)
{
echo "<span style='color: #000;'><center><b>ERROR<br>The image size is too big!</b><center></span>";
}
if (!ereg("image", $type) )
{
echo "<span style='color: #000;'><center><b>ERROR<br>The file is not image!</b><center></span>";
}
?>
</div>
</div>
<div id="footer">
<div id="left_footer"><strong><strong>Copyright �2008 Biolabs.co.uk</strong></strong></div>
<div id="right_footer"><strong><strong>Site created by Jack Moore</strong></strong></div>
</div>
</div>
</body>
</html>

Dentafrice
13-06-2008, 05:50 PM
Just don't use sessions, it isn't even needed, and pointless..

jackass
13-06-2008, 06:00 PM
Just don't use sessions, it isn't even needed, and pointless..

I removed the sessions, and it doesn't work.

Now when you upload an image, it will get rid of the body and squish everything. :(

Want to hide these adverts? Register an account for free!