//========= uploadpic.php ==============
Code: Select all
<?php
$city = $_POST['city'];
$i = $_POST['i'];
$city = trim($city);
$userfile = $_FILES['userfile']['tmp_name'];
$userfile_name = $_FILES['userfile']['name'];
$userfile_size = $_FILES['userfile']['size'];
$userfile_type = $_FILES['userfile']['type'];
if ($userfile == "none") {
echo "<html>";
echo "<head>";
echo "<title>Port Information System: Picture Upload For $city</title>";
echo "<link rel="stylesheet" type="text/css" href="display.css" />";
echo "<META HTTP-EQUIV=Refresh CONTENT="2; URL=".getenv("HTTP_REFERER")."">";
echo "</head>";
echo "<body>";
exit("<center><br><br><br><br><br><br><br><br><br><br><h3>Problem: no file uploaded</h3></center>");
}
if ($userfile_size == 0) {
echo "<html>";
echo "<head>";
echo "<title>Port Information System: Picture Upload For $city</title>";
echo "<link rel="stylesheet" type="text/css" href="display.css" />";
echo "<META HTTP-EQUIV=Refresh CONTENT="2; URL=".getenv("HTTP_REFERER")."">";
echo "</head>";
echo "<body>";
exit("<center><br><br><br><br><br><br><br><br><br><br><h3>Problem: uploaded file is zero length</h3></center>");
}
if ($userfile_size > 800000000) {
echo "<html>";
echo "<head>";
echo "<title>Port Information System: Picture Upload For $city</title>";
echo "<link rel="stylesheet" type="text/css" href="display.css" />";
echo "<META HTTP-EQUIV=Refresh CONTENT="2; URL=".getenv("HTTP_REFERER")."">";
echo "</head>";
echo "<body>";
exit("<center><br><br><br><br><br><br><br><br><br><br><h3>Problem: uploaded file is greater than 8mb</h3></center>");
}
if ($userfile_type == "text/plain") {
echo "<html>";
echo "<head>";
echo "<title>Port Information System: Picture Upload For $city</title>";
echo "<link rel="stylesheet" type="text/css" href="display.css" />";
echo "<META HTTP-EQUIV=Refresh CONTENT="2; URL=".getenv("HTTP_REFERER")."">";
echo "</head>";
echo "<body>";
exit("<center><br><br><br><br><br><br><br><br><br><br><h3>Problem: file is not image</h3></center>");
}
if (!is_uploaded_file($userfile)) {
echo "<html>";
echo "<head>";
echo "<title>Port Information System: Picture Upload For $city</title>";
echo "<link rel="stylesheet" type="text/css" href="display.css" />";
echo "<META HTTP-EQUIV=Refresh CONTENT="2; URL=".getenv("HTTP_REFERER")."">";
echo "</head>";
echo "<body>";
exit("<center><br><br><br><br><br><br><br><br><br><br><h3>Problem: possible file upload attack</h3></center>");
}
header("Location: ".getenv("HTTP_REFERER"));
$upfile = "../litrato/".$userfile_name;
$upfile2 = "../litrato/".$i.$city.".jpg";
rename($upfile, $upfile2);
if (!copy($userfile, $upfile2)){
echo "<center><br><br><br><br><br><br><br><br><br><br><h3>Problem: Could not move file into directory</h3></center>";
exit;
}
//echo "File uploaded successfully<br><br>";
?>
</body>
</html>feyd | use
Code: Select all
tags when posting code; Read [/color][url=http://forums.devnetwork.net/viewtopic.php?t=21171] [color=red][u][b]Posting Code in the Forums[/b][/u][/color][/url].