Heya.
I’m trying my luck on a simple file uploader and grabbed most of the parts I need from other scripts, so… I’m not really sure what I am doing :S
Well, I’m satisfied with my results so far, but there’s one thing that bugs me: When the uploading is done, I only get a few lines of text in a new tab, but I want the picture to pop up in a new tab instead of forcing me to search for it afterwards.
I’m sure it’s possible, but… yeah, I don’t know how.
My script:
[code=“The upload-form”]
[/code][code=“upload_file.php”]<?php
$allowedExts = array(“jpg”, “jpeg”, “gif”, “png”);
$extension = end(explode(".", $_FILES[“file”][“name”]));
if ((($_FILES[“file”][“type”] == “image/gif”)
|| ($_FILES[“file”][“type”] == “image/jpeg”)
|| ($_FILES[“file”][“type”] == “image/png”)
|| ($_FILES[“file”][“type”] == “image/pjpeg”))
&& ($_FILES[“file”][“size”] < 2000000)
&& in_array($extension, $allowedExts))
{
if ($_FILES[“file”][“error”] > 0)
{
echo "Return Code: " . $_FILES[“file”][“error”] . “
”;
}
else
{
echo "Upload: " . $_FILES[“file”][“name”] . “
”;
echo "Type: " . $_FILES[“file”][“type”] . “
”;
echo “Size: " . ($_FILES[“file”][“size”] / 1024) . " Kb
”;
echo "Temp file: " . $_FILES[“file”][“tmp_name”] . “
”;
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "http://website.net/folder/upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo “Invalid file”;
}
?>[/code]
And in the end, it looks like this:
So… how can I change that? My attempts only resulted in syntax-errors because I’m guessing around like hell D: