What Is Wrong With This Code? Help Greatly Appreciated

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
justinram33
Forum Newbie
Posts: 5
Joined: Fri Oct 17, 2008 10:04 pm

What Is Wrong With This Code? Help Greatly Appreciated

Post by justinram33 »

ok, im 13, and just got into PHP about a day ago, and im completly confused! i've been working on this for the past 3 hours! :banghead: basically, im trying to make it so people can upload files to my server... im working in ubuntu Linux too

Here is my HTML Page

<html>
<body>
<form enctype="multipar/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000"/>
Choose a file to upload: <input name="uploadedfile" type="file"/>

<input type="submit" value="Uploaded File" />
</form>
</body>
</html>

and i saved it as "upload.html"

and here is my PHP page

<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php

if ( move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
"../uploads/{$_FILES['uploadFile'] ['name']}") )
{ print '<p> The file has been successfully uploaded </p>';
}
else
{
switch ($_FILES['uploadFile'] ['error'])
{ case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}

?>
</body>
</html>

and when i do it on the computer with the apache server on it, and click the "upload files" tab, it downloads a "uploader.php" file to the computer with apache on it, but when i do it with my other computer (i have the apache on online) it just brings me to a blank page, i have created a folder "uploads" in the same directory as the "uploader.php" and nothing is in there when i try to upload files... any help would be greatly appreciated!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: What Is Wrong With This Code? Help Greatly Appreciated

Post by requinix »

Since you're (apparently) familiar with Linux you know to change the permissions on the upload folder to allow write access for Other?
Check your error_reporting and display_errors INI settings to see if they will display error messages when there are problems. If not, considering turning them on temporarily.
Post Reply