Custom post type with file upload – need to “set as field” instead of “send to editor”

i cant say I’ve tried this but if you have the url of the file and all you need is the file name then you can just change your code from this:

    window.send_to_editor = function(html) {
      imgurl = jQuery('img',html).attr('src');
      jQuery('#upload_image').val(imgurl);
      tb_remove();
    }

to this:

    window.send_to_editor = function(html) {
      imgurl = jQuery('img',html).attr('src');
      filename = substring(imgurl.lastIndexOf("https://wordpress.stackexchange.com/"), imgurl.length);
      jQuery('#upload_resource').val(filename);
      tb_remove();
    }

and this way your “send to editor” button will insert just the file name.