groog
07-27-2007, 05:24 AM
Ok I read the post rafiki made and didn't understand it because I'm very new at php and I only know what I read on w3c from tutorial 1 to uploading files. I did read everything and I didn't just do a cheap copy and paste of this script.
http://groogstestpages.freehostia.com/upload.php
try uploading a gif or jpeg
first page
<html>
<head>
<title>
Upload Test
</title>
<link href="upload.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<form action="upload_file.php" method="POST" enctype="multipart/form-data">
<label for="file">File:</label>
<input type="file" name="file" id="file">
<input type="submit" name="submit" value="Upload">
</form>
</div>
</body>
</html>
Second Page
<html>
<head>
<title>
Upload Test Complete
</title>
<link href="upload.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<?php
if (($_FILES['file']['type'] == "image/gif")
|| ($_FILES['file']['type'] == "image/pjpeg"))
{
if ($_FILES['file']['error'] > 0){
echo "Error" . $_FILES['file']['error'] . "<br />";
}
else
{
echo "Name: " . $_FILES['file']['name'] . "<br />";
echo "Type: " . $_FILES['file']['type'] . "<br />";
echo "Size: " . ($_FILES['file']['size'] / 1024) . "KB <br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
move_uploaded_file($_FILE['file']['tmp-name'], "uploads/" . $_FILES['file']['name']);
echo "stored in: " . "uploads/" . $_FILES['file']['name'];
}
}
else
{
echo "invalid file<br>";
var_dump($_FILES);
}
?>
</div>
</body>
</html>
I'm hoping you guys can see something here because the guys at php freaks couldn't figure it out (some php gurus they are!). I do have a folder set up named uploads in the same directory as this file so that's all set up.
http://groogstestpages.freehostia.com/upload.php
try uploading a gif or jpeg
first page
<html>
<head>
<title>
Upload Test
</title>
<link href="upload.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<form action="upload_file.php" method="POST" enctype="multipart/form-data">
<label for="file">File:</label>
<input type="file" name="file" id="file">
<input type="submit" name="submit" value="Upload">
</form>
</div>
</body>
</html>
Second Page
<html>
<head>
<title>
Upload Test Complete
</title>
<link href="upload.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<?php
if (($_FILES['file']['type'] == "image/gif")
|| ($_FILES['file']['type'] == "image/pjpeg"))
{
if ($_FILES['file']['error'] > 0){
echo "Error" . $_FILES['file']['error'] . "<br />";
}
else
{
echo "Name: " . $_FILES['file']['name'] . "<br />";
echo "Type: " . $_FILES['file']['type'] . "<br />";
echo "Size: " . ($_FILES['file']['size'] / 1024) . "KB <br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
move_uploaded_file($_FILE['file']['tmp-name'], "uploads/" . $_FILES['file']['name']);
echo "stored in: " . "uploads/" . $_FILES['file']['name'];
}
}
else
{
echo "invalid file<br>";
var_dump($_FILES);
}
?>
</div>
</body>
</html>
I'm hoping you guys can see something here because the guys at php freaks couldn't figure it out (some php gurus they are!). I do have a folder set up named uploads in the same directory as this file so that's all set up.