-2

I am thinking about builing a windows forms app that create and publish new drupal nodes content.

Drupal related information:

node type is product witch has these fields:

title as string,

field_price as decimal,

field_main_image as a single image,

field_more_images as multiple images,

drupal has a web form to do that and that form has these details:

action = "http://localhost/commerce/node/add/product"

encrypt = "multipart/form-data"

accept-charset = "UTF-8"

method = "post"

text field title

fileupload field files[field_main_image_und_0]

text field field_price[und][0][value]

fileupload field files[field_more_images_und_0] (one for each additional image)

c# win forms related info:

textbox "title";

textbox "mainImageFilename" //with path

textbox "price"

that's alot of information and ofcourse I'm asking for helpting tips..

I wrote this code witch has alot of mistakes and holes...

HttpWebRequest req;

req = (HttpWebRequest)HttpWebRequest.Create("http://mydrupalsite.com/node/add/product");

req.Method = "POST";

req.ContentType = "application/x-www-form-urlencoded"; //quest: is this ture?

//quest: how to add the data and files I want to upload to the request?

req.GetResponse();

could you help me doing that...

Wisamx
  • 117
  • 1
  • 17
  • 1
    Possible duplicate of [this](http://stackoverflow.com/questions/26857/how-do-you-programmatically-fill-in-a-form-and-post-a-web-page). Same principle. – Nasreddine Oct 30 '11 at 20:46
  • @Nacereddine i have seen the link you give to me... but it dosen't discuss the uploading of photos (files) and that is the main part of my question... could you please help me more... thank you... – Wisamx Oct 30 '11 at 22:46
  • 1
    this one http://stackoverflow.com/questions/566462/upload-files-with-httpwebrequest-multipart-form-data should do the trick – Nasreddine Oct 30 '11 at 22:52

1 Answers1

0

I think you might be better off looking at the services module for doing this instead of hacking the form submission.

See http://drupal.org/project/services

messedup
  • 1,098
  • 1
  • 10
  • 12