You need to sign in to do that
Don't have an account?
Continued trouble creating an Attachment object
I thought I had this working but I was going about it all wrong. The key section of code I'm having trouble with is below. This works except that I'm trying to grab the full path from the web form and passing it below as the variable 'error_log_file'.
Being new to this type of development, I didn't realize that you can't provide the local path to the browser. Instead, I'm assuming that the user has to enter this using a standard HTML input where "type=file". I can code for this but I don't see then how I would provide that file handle to the code below. Can anyone provide some simple examples of how this is done.
I'm sure this is pretty basic stuff. I'm hoping that I'm missing something fairly easy here. THANKS!!
Attachment attachment1 = new Attachment();SObject [] sObjects1 = new SObject[1];sObjects1[0] = attachment1;
if (error_log_l == "yes") {
File f = new File(error_log_file);
try {InputStream is = new FileInputStream(f);
byte[] inbuff = new byte[(int)f.length()];is.read(inbuff);
attachment1.setBody(inbuff);
} catch (Exception e){System.out.print(e);}
attachment1.setName("error.log");attachment1.setParentId(
sess_curr_case_id);}