Log in

View Full Version : Users not allowed to upload files on my free hosting for my web site?



chopficaro
12-30-2009, 07:50 AM
im trying to learn php.
so ive been trying out code i found on w3schools.com, to see exactly how it works
everything has worked so far
but i got to the chapter about users uploading files, copied and pasted the code, tried it out, it seemed to be working, but i was unable to find the file on the server once it was uploaded
i suspect that the free hosting service that i am using is blocking my ability to allow the users to upload files.

is this possible?

once the submit button is pressed, there is even a confirmation message telling the user where the file is stored, and it appears, but the file cant be found in my ftp program or in cpanel

if anyone knows a free web hosting service that definitely does not **** with what php is allowed to do, i would like to know. if they have messed with this aspect of php, then who knows what else theyve ****ed with. this is frustrating, its making me think that i have made a mistake when i have not, and i am wasting my time looking for mistakes that do not exist





FOR REFERENCE here is my code, but i am almost certain that it is correct




helloworld.php:



<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>





upload_file.php:



<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_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 />";

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: " . "upload/" . $_FILES["file"]["name"];
}
}
?>

chopficaro
12-30-2009, 10:25 AM
i fixed the problem, it was folder permissions

traq
12-31-2009, 06:03 AM
I wouldn't be so upset about any restrictions your *free* web host may have made on how much PHP functionality is available to you.

As for finding your problems, yes, that can be frustrating. Folder permissions, for example, are rarely covered in tutorials. When they are mentioned, it's usually vague and easily overlook-able. When you figure it out, it's kinda like realizing you computer won't turn on because -duh- it's not plugged in. :D