reportingsjr Posted April 11, 2006 Share Posted April 11, 2006 I know there is code for this but here is the question:How would I put a file into a folder in your website server? I would like to be able to upload images into a folder called /images but dont know the coding. How would I do this?ex: upload picture /tut into folder /images on the server. I would like to know the coding for this please!Thanks for reading this!-reportingsjr Link to comment Share on other sites More sharing options...
calvin182 Posted April 12, 2006 Share Posted April 12, 2006 upload.php: <strong>Upload an image:</strong><br/><br/><em>Max upload size: 2 megabyte (2,097,152 bytes)</em><!-- The data encoding type, enctype, MUST be specified as below --><form enctype="multipart/form-data" action="upload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="2097152" /> <!-- Name of input element determines name in $_FILES array --> <input name="uploaddirectory" type="text" value="/home/DOMAINUSER/public_html/images/" size="50"/> <input name="userfile" type="file" size="50"/><br/> <input type="submit" value="Add to gallery" /></form> When you have your path figured out, change the type="text" to type="hidden".results.php: <?php// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead// of $_FILES.$uploaddir = $_GET['uploaddirectory'];$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File was successfully uploaded!"; $backmessage = "Upload another"; } else { echo "Upload failed!"; $backmessage = "Back to upload";}echo "<br/><a href=\"upload.php\" title=\"$backmessage\">$backmessage</a>";?> I hope that helps! Link to comment Share on other sites More sharing options...
reportingsjr Posted April 15, 2006 Author Share Posted April 15, 2006 Hmm.. ill test it soon. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 19, 2006 Share Posted April 19, 2006 Also take a look here:http://www.php.net/manual/en/features.file-upload.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now