• I need to make use of the upload function in other plugins. For example having an input field with “Upload file” and then they will get the file URL automatically in the input field. And I want it uploaded to the Upload folder.

    Anyone that understands? I have googled and searched the forum in vain. Found nothing yet. Anyone that can point me in the right direction or give me some tips? Is there anyway to call the upload function outside of making and editing a post/page?

Viewing 3 replies - 1 through 3 (of 3 total)
  • if you are just looking for a file upload capability for users, I use the cForms plugin….. lets me allow DJs to upload music mixes to my site

    you just set up a form with it, and make one of the fields a file upload field

    I am looking for an upload field as well, but for the admin side. I want to add one to datafeedr random adds. BUt somehow my added code:

    <?php
    	function my_admin_scripts() { // function to load scripts
    	wp_enqueue_script('media-upload');
    	wp_enqueue_script('thickbox');
    	wp_register_script('my-upload', WP_PLUGIN_URL.'/my-script.js', array('jquery','media-upload','thickbox'));
    	wp_enqueue_script('my-upload');
    	}
    
    	function my_admin_styles() {
    	wp_enqueue_style('thickbox');
    	}
    
    	if (isset($_GET['page']) && $_GET['page'] == 'my_plugin_page') {
    	add_action('admin_print_scripts', 'my_admin_scripts'); // load own javascripts
    	add_action('admin_print_styles', 'my_admin_styles'); // load own css
    	}
    
    	?>
    		<tr valign="top">
    		<th scope="row">Upload Image</th>
    		<td><label for="upload_image">
    		<input id="upload_image" type="text" size="36" name="upload_image" value="" />
    		<input id="upload_image_button" class="thickbox" type="button" value="Upload Image" />
    		<br />Enter an URL or upload an image for the banner.
    		</label></td>
    		</tr>

    Does not seem to work. I have found this code and adjusted it slightly, but the newly added image uplaod button does not open the WP uploader pop-up….

    Latest code for image upload field using ThickBox in (DataFeedr) plugin:

    <?php
    // Add code for upload field
    
    function my_admin_scripts() { // function to load scripts
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
    wp_register_script('my-upload', WP_PLUGIN_URL.'/datafeedr-ads/my-script.js', array('jquery','media-upload','thickbox'));
    wp_enqueue_script('my-upload');
    }
    
    function my_admin_styles() {
    wp_enqueue_style('thickbox');
    }
    
    if (isset($_GET['page']) && $_GET['page'] == 'datafeedr-ads') {
    add_action('admin_print_scripts', 'my_admin_scripts'); // load own javascripts
    add_action('admin_print_styles', 'my_admin_styles'); // load own css
    }
    ?>
    <tr valign="top">
    
    			<td><label for="upload_image">
    			<div class="clear" style="height:10px;"></div>
    			Enter an URL or upload an image for the ad.		<br />
    			<input id="upload_image_button"  type="button" value="Insert Image" />
    			</label></td>
    			</tr>
    				<div class="clear" style="height:10px;"></div>
    		<div>
    			<a href="javascript:;" onclick="addEvent();" class="button-secondary">Add Box</a>
    			<input name="submit-edit-group" type="submit" value="Save Changes" class="button-secondary">
    
    			<div class="clear"> </div>

    Here the JavaScript (my-script.js):

    jQuery(document).ready(function() {
    
    jQuery('#upload_image_button').click(function() {
     formfield = jQuery('#upload_image').attr('name');
     tb_show('','media-upload.php?type=image&TB_iframe=true');
     return false;
    });
    // send url back to plugin editor
    
    window.send_to_editor = function(html) {
     imgurl = jQuery('img',html).attr('src');
     jQuery('#dfrads_textarea').val(imgurl);
     tb_remove();
    }
    
    });

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Want to make use of the upload function in other plugins’ is closed to new replies.