PDA

View Full Version : Problem


Guy G
02-21-2005, 09:19 PM
I have a script


<?php
echo "<head>
<title>Free Image hosting</title>
<STYLE TYPE=\'text/css\'>
/* CSS generated at csscreator.com */
A{color:FF6600; text-decoration:none; }
A:Visited{color:FF6600; }
A:Hover{color:000000; text-decoration:underline; }
</STYLE>

</head>

<body background=\"img/wall.gif\" link=\"#FF6600\" vlink=\"#FF6600\" alink=\"#FF6600\">

<p align=\"center\">&nbsp;</p>
<div align=\"center\">
<table border=\"1\" width=\"800\" bordercolor=\"#000000\" cellspacing=\"3\" cellpadding=\"3\">
<tr>
<td height=\"74\" width=\"310\" bordercolor=\"#000000\" bgcolor=\"#FFFFFF\">
<p align=\"center\">
<img border=\"0\" src=\"img/logo.gif\" width=\"292\" height=\"74\"></td>
<td height=\"1\" width=\"10\" bordercolor=\"#000000\" bgcolor=\"#FFFFFF\">
<p align=\"center\">
<img border=\"0\" src=\"img/ad1.gif\" width=\"468\" height=\"60\" align=\"right\"></td>
</tr>
<tr>
<td width=\"1044\" bordercolor=\"#000000\" bgcolor=\"#FFFFFF\" colspan=\"2\">
<p align=\"center\"><span style=\"font-size: 9pt\"><br>
</span><font face=\"Verdana\" style=\"font-size: 9pt\">Welcome to <i>
<font color=\"#FF6600\">****</font></i>, a fast and reliable <b>free</b>
image hosting service, no registration is required and you may share
your images, instantly!<br>
&nbsp;</font></p>
<p align=\"center\"><font face=\"Verdana\" style=\"font-size: 9pt\">
<FORM ENCTYPE=\"multipart/form-data\" ACTION=\"index.php\" METHOD=\"POST\">
<p align=\"center\">File: <INPUT TYPE=\"file\" NAME=\"userfile\"> <br>
<br>
<font face=\"Verdana\" style=\"font-size: 9pt\">Image Types Allowed:<b> jpg, png,
gif</b><br>
Maximum Size: <b>200kb</b></font><br>
<br>
<INPUT TYPE=\"submit\" VALUE=\"Upload\">
</p>
</FORM>
</font></p><p align=\"center\">";


$path = "images/";
$max_size = 200000;

if (!isset($HTTP_POST_FILES['userfile'])) exit;

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "<center>The file is too big</center><br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {

if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists<br>\n"; exit; }

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "<center>upload failed!</center><br>\n"; exit; } else { echo "<center>upload sucessful</center><br>\n"; }

echo "<center>File Name: http://www..com/images/".$HTTP_POST_FILES['userfile']['name']."</center><br>\n";
} else { echo "<center>Wrong file type</center><br>\n"; exit; }

}



echo "<p align=\"center\"><font face=\"Verdana\" style=\"font-size: 9pt\"><br>
&nbsp;</font></td>
</tr>
</table>
</div>
<p align=\"center\"><font face=\"Verdana\" size=\"1\">? 2005, All rights
reserved<br>
</font><font face=\"Verdana\" size=\"2\"><a href=\"about.php\">About</a> |
<a href=\"contact.php\">Contact</a> | <a href=\"faq.php\">FAQ</a> |
<a href=\"tos.php\">TOS</a></font></p>";

?>


It is a last attempt of trying to do anything with it.... not working...
When i go into the main page it wont show the footer, this part:

echo "<p align=\"center\"><font face=\"Verdana\" style=\"font-size: 9pt\"><br>
&nbsp;</font></td>
</tr>
</table>
</div>
<p align=\"center\"><font face=\"Verdana\" size=\"1\">? 2005, All rights
reserved<br>
</font><font face=\"Verdana\" size=\"2\"><a href=\"about.php\">About</a> |
<a href=\"contact.php\">Contact</a> | <a href=\"faq.php\">FAQ</a> |
<a href=\"tos.php\">TOS</a></font></p>";


and when i upload it does.... how would i display it before and after i upload it?

Thanks all

MentaL
02-21-2005, 09:39 PM
Help would be fantastic :)!

Jolten
02-21-2005, 09:58 PM
If it were my page I'd reverse how you have the tags. Your also missing a couple tag and have some extra tags as well


<?php
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'filename');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Free Image hosting</title>

<style type='text/css'>

/* CSS generated at csscreator.com */
a {
color:FF6600; text-decoration:none;
}
a : visited {
color:FF6600;
}
a : hover {
color:000000; text-decoration:underline;
}
</style>

</head>

<body background="img/wall.gif">

<p align="center">&nbsp;</p>
<div align="center">
<table border="1" width="800" bordercolor="#000000" cellspacing="3" cellpadding="3">
<tr>
<td height="74" width="310" bordercolor="#000000" bgcolor="#FFFFFF">
<p align="center">
<img border="0" src="img/logo.gif" width="292" height="74">
</p>
</td>
<td height="1" width="10" bordercolor="#000000" bgcolor="#FFFFFF">
<p align="center">
<img border="0" src="img/ad1.gif" width="468" height="60" align="right">
</p>
</td>
</tr>
<tr>
<td width="1044" bordercolor="#000000" bgcolor="#FFFFFF" colspan="2">
<p align="center">
<font face="Verdana" style="font-size: 9pt\">Welcome to <em>
<font color="#FF6600">****</font></em>, a fast and reliable <strong>free</strong>
image hosting service, no registration is required and you may share
your images, instantly!
</font>
</p>
<p align="center">
<form enctype="multipart/form-data" action="index.php" method="post">
<p align="center">
File: <input type="file" name="userfile" />
<br />
<br />
<font face="Verdana" style="font-size: 9pt">Image Types Allowed:<strong> jpg, png, gif</strong>
<br />
Maximum Size: <strong>200kb</strong></font>
<br />
<br />
<input type="submit" VALUE="Upload">
</p>
</form>
</p>
<p align="center">

<?php
$path = "images/";
$max_size = 200000;

if (!isset($HTTP_POST_FILES['userfile'])) exit;

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "<center>The file is too big</center><br />\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {

if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists<br />\n"; exit; }

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "<center>upload failed!</center><br />\n"; exit; } else { echo "<center>upload sucessful</center><br />\n"; }

echo "<center>File Name: http://www.eh5.com/images/".$HTTP_POST_FILES['userfile']['name']."</center><br />\n";
} else { echo "<center>Wrong file type</center><br />\n"; exit; }

}

?>

</p>
</td>
</tr>
</table>
</div>
<p align="center">
<font face="Verdana" size="1">&copy; 2005, All rights reserved<br /></font>
<font face="Verdana" size="2"><a href="about.php">About</a> | <a href="contact.php">Contact</a> | <a href="faq.php">FAQ</a> | <a href="tos.php">TOS</a></font>
</p>
</body>
</html>

Guy G
02-21-2005, 10:00 PM
Its not for vb.... upper defines still needed?

Jolten
02-21-2005, 10:01 PM
not really but defining the script will help some security a little. And the error reporting helps track errors obviously. You could kill the upper defines if you wanted to.

Guy G
02-21-2005, 10:13 PM
not really but defining the script will help some security a little. And the error reporting helps track errors obviously. You could kill the upper defines if you wanted to.
Ok thanks.
Ill test it asap

Jolten
02-21-2005, 11:01 PM
There's actually an error or two that I didn't see before. You're exiting the script with the exit commands. This is why nothing is showing after the exit command.

This may work better

<?php
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'Contest_a');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Free Image hosting</title>

<style type='text/css'>

/* CSS generated at csscreator.com */
a {
color:#FF6600; text-decoration:none;
}
a : visited {
color:#FF6600;
}
a : hover {
color:#000000; text-decoration:underline;
}
</style>

</head>

<body background="img/wall.gif">

<p align="center">&nbsp;</p>
<div align="center">
<table border="1" width="800" bordercolor="#000000" cellspacing="3" cellpadding="3">
<tr>
<td height="74" width="310" bordercolor="#000000" bgcolor="#FFFFFF">
<p align="center">
<img border="0" src="img/logo.gif" width="292" height="74">
</p>
</td>
<td height="1" width="10" bordercolor="#000000" bgcolor="#FFFFFF">
<p align="center">
<img border="0" src="img/ad1.gif" width="468" height="60" align="right">
</p>
</td>
</tr>
<tr>
<td width="1044" bordercolor="#000000" bgcolor="#FFFFFF" colspan="2">
<p align="center">
<font face="Verdana" style="font-size: 9pt\">Welcome to <em>
<font color="#FF6600">****</font></em>, a fast and reliable <strong>free</strong>
image hosting service, no registration is required and you may share
your images, instantly!
</font>
</p>

<form enctype="multipart/form-data" action="index.php" method="post">
<p align="center">
File: <input type="file" name="userfile" />
<br />
<br />
<font face="Verdana" style="font-size: 9pt">Image Types Allowed:<strong> jpg, png, gif</strong>
<br />
Maximum Size: <strong>200kb</strong></font>
<br />
<br />
<input type="hidden" value="1" name="ans"/>
<input type="submit" VALUE="Upload" />
</p>
</form>

<p align="center">

<?php
$ans = $_POST['ans'];

$path = "images/";
$max_size = 200000;

if ($ans ==1){

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
echo "<center>The file is too big</center><br />";
}

if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {

if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) {
echo "The file already exists<br />";
}

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) {
echo "<center>upload failed!</center><br />";
} else {
echo "<center>upload sucessful</center><br />";
}

echo "<center>File Name: http://www.eh5.com/images/".$HTTP_POST_FILES['userfile']['name']."</center><br />";
} else {
echo "<center>Wrong file type</center><br />";
}

}
}
?>

</p>

<p align="center">
&copy; 2005, All rights reserved<br />
<a href="about.php">About</a> | <a href="contact.php">Contact</a> | <a href="faq.php">FAQ</a> | <a href="tos.php">TOS</a>
</p>
</td>
</tr>
</table>
</div>
</body>
</html>


Also note, when testing this on my server... it doesn't work and I didn't feel like going through your php to figure out why.

MentaL
02-22-2005, 09:09 AM
code above works :) thanks. just need to add thumbnail now to it ;)!