unable to send jpg, or png, via webrequest... the file gets sent, but its an empty file...

 
bool sendImage (string symbol, string tf) { 
  
  string fileName = StringConcatenate(symbol,"_",tf,".jpg");
  Print("FILENAME = " + symbol);
  string fileType="image/jpg";
  
  int    res;     // To receive the operation execution result 
  char   data[];  // Data array to send POST requests 
  char   file[];  // Read the image here 
  char result[];
   
  string str=""; 
  string auth,sep="-------1234097zxcvasdfqwer"; // multipart data separator 
   
  string strResult,result_header;
  //--- A file is available, try to read it 
   if(fileName!=NULL && fileName!="") 
     { 
      res=FileOpen(fileName,FILE_READ|FILE_BIN); 
      if(res<0) 
        { 
         Print("Error opening the file \""+fileName+"\""); 
         return(false); 
        } 
      //--- Read file data 
      if(FileReadArray(res,file)!=FileSize(res)) 
        { 
         FileClose(res); 
         Print("Error reading the file \""+fileName+"\""); 
         return(false); 
        } 
      //--- 
      FileClose(res); 
     }   
     
     
  //--- If there is a data file, send it to the server 
   Print("ARRAY SIZE = " + ArraySize(file));
   if(ArraySize(file)!=0) 
     { 
      //--- Form the request body 
      str="--"+sep+"\r\n"; 
      str+="Content-Disposition: form-data; name=\"files[]\"; filename=\""+fileName+"\"\r\n"; 
      str+="\r\nContent-Type: "+fileType+"\r\n\r\n"; 
      
      Print("STRING 1 = " + str);
      
      res =StringToCharArray(str,data); 
      res+=ArrayCopy(data,file,res-1,0); 
      res+=StringToCharArray("\r\n--"+sep+"--\r\n",data,res-1); 
      ArrayResize(data,ArraySize(data)-1); 
      //--- Form the request header 
      str="Content-Type: multipart/form-data; boundary="+sep+"\r\n"; 
      //--- Reset error code 
      ResetLastError(); 
      //--- Request to send an image file to the server 
      
      res=WebRequest("POST","http://localhost/uploadMqlImage",str,5000,data,result,str); 
      //--- check the request result 
      Print("RESULT HEADERS - " + str);
       
     } 
   return true;
}
 
i tried to upload the files - one clearly shows the snapshot from mt4, the other is what is received, basically just a shell... no actual image... thoughts/suggestions?
 
palmerkf #:
i tried to upload the files - one clearly shows the snapshot from mt4, the other is what is received, basically just a shell... no actual image... thoughts/suggestions?

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
how long does it typically take to get feedback?
 
palmerkf #: how long does it typically take to get feedback?

This is not a help desk, it is a user's forum. You have already received feedback twice. Do not ping your posts.

 
palmerkf #:
how long does it typically take to get feedback?

Feedback??

Do you mean a reply to your post?

It depends on whether anyone has the knowledge and interest to respond as well as when they may get around to reading your topic.

 

William, yes sir, i understand that this is not a help desk, as i used to work at an IT help desk many years ago.. I'm asking fellow coders for suggestions, help, advice, assistance of any kind...  i have NOT received any feedback pertaining to my question...  i tried to send screenshots to show the difference of images - before being send and after, but i dont know if that worked as i cannot see a link to the images on my post..  I have noticed that you are an expert coding mql, i see your posts all over...  have you any suggestions?  i have spent hours and hours trying to get this to work.. i have only come here as a last resort.. what should be a 5 min task has now exhausted my efforts...


Keith - yes i do i mean a reply to my post... is there somewhere else i should be look for response???  i'm new here...


and then i tried typing in more details of the exact issue i was facing, but couldnt figure that out either...  so i apoligize if i have missed steps or havent provided enough info...  

 
any suggestions?
 
any suggestions?
 
palmerkf #: any suggestions?

Just think about it please — In order to test your code we would need to recreate similar conditions of setting up a webservice in order to be able to receive the image files being uploaded by your code.

Do your really think that ...

  1. Just anyone will have that already setup for such a test?
  2. Anyone will be willing to go to all the trouble of setting it up, just to test your code?

No, most will not!

So, if you really want someone to test your code and help you out, create the conditions for others to be able to do so.

Or better still, debug your own code on both sides, not just on the MQL side. Monitor what is being send out by the MQL side and what is being received on the other end.

That's what software developers do. They debug their own code and systems.

Reason: