Problem with upload images
-
Hi guys! I created a new plugin, but now I want to upload photos to the plugin admin panel and i using the following code from this site :
function my_admin_scripts() { wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_register_script('my-upload', plugins_url('tz_background/assets/js/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'] == 'tz-backgraund-plugin') { add_action('admin_print_scripts', 'my_admin_scripts'); add_action('admin_print_styles', 'my_admin_styles'); }<code>and my-script.js</code>(function($) { $('document').ready(function() { $('#upload_image_button').click(function() { formfield = $('#upload_image').attr('name'); tb_show('', 'media-upload.php?type=image&TB_iframe=true'); return false; }); window.send_to_editor = function(html) { imgurl =$('img', html).attr('src'); $('#upload_image').val(imgurl); tb_remove(); } }); }(jQuery));
How can I have a directory where to upload images and how can I get the names of the pictures, because I want to record the names of the images in the wp_options as json?
- The topic ‘Problem with upload images’ is closed to new replies.