How to upload an html form containing a pdf file from an extension written in JavaScript to a URL?


i need send form adobe illustrator extension url.

previously using c++ write plugin same functionality indesign.

 

to implement extension photoshop , illustrator used html5 ui, jquery, angularjs implement functionalities of extension.

now need send pdf url in form of html form.

 

we using curl c++ purpose. can use js same here?

 

i tried use ajax turned out cannot make cross-domain call it, , extension doesn't have domain name or ip or anything. extension running photoshop , illustrator , need upload form (containing pdf) url.

how can it?

 

any appreciated. have added c++ code function below.

 

bool wpconnection::uploadpdftoserver( const char* pdfpath, const char* urlinfo )
{

    bool16 uploadstatus = false;

 

    try // abhishek

    {

   // url
   char connectionurl[256] = {0};

 

   // update project panel tree
   const char* username = g_wpdetailsvector.at(0).c_str();
   const char* password = g_wpdetailsvector.at(1).c_str();
   const char* projectid = g_wpdetailsvector.at(2).c_str();
   const char* statusid = g_wpdetailsvector.at(3).c_str();
   const char* pagenumber = g_wpdetailsvector.at(4).c_str();

 

   strcpy(connectionurl, urlinfo);
   strcat(connectionurl, "/indd_filetransfer.asp?");
   strcat(connectionurl, "username=");
   strcat(connectionurl, username);
   strcat(connectionurl, "&password=");
   strcat(connectionurl, password);
   strcat(connectionurl, "&project_id=");
   strcat(connectionurl, projectid);
   strcat(connectionurl, "&status_id=");
   strcat(connectionurl, statusid);
   strcat(connectionurl, "&item_numbers=");
   strcat(connectionurl, pagenumber);

 

  
   curlcode result = curle_failed_init;
  
  
   struct curl_httppost *formpost=null;
   struct curl_httppost *lastptr=null;
  
  
   curl_formadd(&formpost,
   &lastptr,
   curlform_copyname, "file",
   curlform_file, pdfpath,
   curlform_contenttype, "pdf",
   curlform_end);

 

   if(fcurl)
   {
        // clearing connection info
   this->clearconnectioninfo();
      
        //set options curl easy handle
   curl_easy_setopt(fcurl, curlopt_url, connectionurl);
   curl_easy_setopt(fcurl, curlopt_httppost, formpost);
      
   result = curl_easy_setopt (fcurl, curlopt_noprogress, false);
   result = curl_easy_setopt (fcurl, curlopt_progressfunction, progress_callback);
   //don't verify peer.
   curl_easy_setopt(fcurl, curlopt_ssl_verifypeer, false);
  
      
      
        //use proxy information
   if( g_useproxy == ktrue )
   {
   curl_easy_setopt( fcurl, curlopt_proxy, g_wpdetailsvector.at(5).c_str() );
   if( g_proxyauthentication == ktrue )
   {
   curl_easy_setopt( fcurl, curlopt_proxyuserpwd, g_wpdetailsvector.at(6).c_str() );
   }
   }

 

   result = curl_easy_perform(fcurl);
   this->getconnectioninfo(fcurl);

 

   curl_formfree(formpost);
   }

 

   if( (result == curle_ok) && (fhttpstatus == 200) /*&& (fresponsestatus == -1)*/)
   {
   g_uploadpercent = 100;
   uploadstatus = true;
   }
   else
   {
   g_uploaderror = true;
   }

    }

    catch(...)

    {

   g_uploaderror = true;

    }

 

    return uploadstatus;

}

can't use standard html form upload page action?

 

<form method="post" enctype="multipart/form-data" action="http://www.mysite.com/upload.php">

<input name="pdf_file" type="file" />

<input type="submit" />

</form>



More discussions in Illustrator SDK


adobe

Comments

Popular posts from this blog

after effects warning: unable to create drawing surface

Maximum number of authorizations reached!