i heard there was a way to upload to directories from web pages through PHP...? I need to learn how to write a lil pup that will upload images for a photo gallery I'm coding... Is there a function that uploads? thanks for advice B)
im sure you can try something with this Code: <?php if ($HTTP_POST_VARS['submit']) { if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) { $error = "You did not select a file to upload"; unlink($HTTP_POST_FILES['file']['tmp_name']); } else { //a file was uploaded do something $maxfilesize=10240; if ($HTTP_POST_FILES['file']['size'] > $maxfilesize) { $error = "The selected file is too large, it must be less than $maxfilesize bytes."; unlink($HTTP_POST_FILES['file']['tmp_name']); } else { //the file is under the specified number of bytes do something if($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg" AND $HTTP_POST_FILES['file']['type'] !="image/jpeg") { $error = "This file type is not allowed"; unlink($HTTP_POST_FILES['file']['tmp_name']); } else { //the file is the correct format do something copy($HTTP_POST_FILES['file']['tmp_name'],"/finallocation/".$HTTP_POST_FILES ['file']['name']); print "Your file has been successfully uploaded to /finallocation/".$HTTP_POST_FILES['file']['name']; exit; } } } } <html> <head></head> <body> <form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data"> <?=$error?> <br><br> Choose a file to upload:<br> <input type="file" name="file"><br> <input type="submit" name="submit" value="submit"> </form> </body> </html>
wow, did you just write that? I'm gonna study that cuase I want to see how it works too, not just copy and paste it. Thanks Alex! B)