Support » Plugins » Hacks » Image upload via form on php script

  • Resolved Whithil XBR


    I’m using a simple XMLRPC form to create new posts for a real estate website, so people from there would be able to quickly and easily add new posts.
    Everything went ok, even the custom fields, now I just need a way to send images to the wordpress media library and get the link from the uploaded image in a custom field. But I couldn’t figure out this part.
    Is there a way to do it?

    Any help will be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Maybe this post will help? It uses the Settings API (which everybody should be using anyway).

    Multiple Upload Inputs In A WordPress Theme Options Page

    Thanks but I already found this code, and it worked fine to upload the images:

    $blogid=1; //Post ID
    $filetype = "image/jpeg";
    $filename = "remote_filename.jpg";
    xmlrpc_set_type($file,'base64'); // <-- required!
    $params = array($blogid,$username,$password,
    $request = xmlrpc_encode_request('wp.uploadFile',$params);
    $result = go($request,$rpcurl);
    function go($request,$rpcurl){
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_POSTFIELDS,$request );
        $result = curl_exec($ch);

    now I just need to get the url from the uploaded file in wordpress’ “media-library”.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Image upload via form on php script’ is closed to new replies.