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:
Code:<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:
Code:<?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"]; } } ?>



Reply With Quote

Bookmarks