Ok, so i have been using html for quite a while and am learning how to use php functions now. I have a domain and am using a hosting site to host my files, i have a php file that allows users to upload pictures to a specified file but i keep getting error messages. the function works on my server, so i know it is correct, so i believe that this is probably a security issue with the site that i am using to host the file. so i would like to use my server to handle the php and accept the upload. i tried just entering my url of the php file on my server in the #post line but i should have known it would not be that simple. i researched this and it looks like i need to set up a "listening page" php file and a variable that defines the url. since i am very new to this i was hoping someone could help me with specific instructions so that i can see the mechanics of this and understand it better. this is my code:
<form enctype="multipart/form-data" action="upload.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br/> <input type="submit" value="Upload" />` once the user submits the file it is handled by the following code
$target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } if ($uploaded_size > 10000) { echo "Your file is too large.<br>"; $ok=0; } if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } so how to i get the form to call this function on my server? http://www.server-name/folder/upload.php
action="..."bit in the<form>tags is for. It specifies the URl to which the form data should be submitted. In your case, your server-side script would have to be calledupload.php, in the same directory/folder as the form was loaded from. And WARNING WARNING WARNING: You have no error handling/validation on your upload handling code, and are using a user-specified filename as the storage destination. This allows malicious users to scribble on any file on your server they want. You're just begging to get pwn3d.