• Hello all,

    I am just now getting into plugin’s and what I would like to do is create a pretty simple plug in that will upload a pdf file (It is referenced as a bulletin) and then add a post. At this point, I’m just trying to get the file uploaded but it’s not working how I would like. I was unable to find a built-in function that would upload a file like the media page will. Here is what I have so far, but it will not upload a file at all. Any idea why?

    <?php
    function bulletin_content() {
    	?>
    	<div class="wrap">
    	<h2>Add Bulletin</h2>
    	<?php
    	if (isset($_POST['uploadfile'])) {
    		?>
    		<div style="border: 1px solid #62A400;background-color:#DDFFAA;margin:10px;padding:10px;line-height:25px;">
    		<?php
    		$target_path = "/bulletins";
    		move_uploaded_file($_FILES["uploadfile"]["tmp_name"], $target_path . $_FILES["uploadfile"]["name"]);
    		?>
    		The bulletin has been uploaded successfully!
    		</div>
    		<?php
    	}
    	?>
    	<form name="quoteform" id="quoteform" class="wrap" method="post" action="/blog/wp-admin/admin.php?page=bulletin">
    		<div style="border: 1px solid #DFDFDF;background-color:#FFFFFF;margin:10px;padding:10px;line-height:25px;">
    		<p>Please use the form below to upload a bulletin to the website.</p>
    		<p><input type="file" name="uploadfile" size="30" class="button bold" style="font-weight:bold;padding:10px;" /></p>
    		<p><input type="submit" name="save" class="button bold" style="font-weight:bold;" value="Save &raquo;" /></p>
    		</div>
    	</form>
    	</div>
    	<?php
    }
    ?>
  • The topic ‘Upload File’ is closed to new replies.