Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Patricia Harvath
    Connect PHP and File Attachment... Please Help ... MY LAST...
    Topic posted May 3, 2013 by Patricia HarvathBronze Medal: 1,250+ Points 
    2399 Views, 44 Comments
    Title:
    Connect PHP and File Attachment... Please Help ... MY LAST DAY
    Content:

    Hi,

    This is my last day and I want to fix this before I go...

    Error when attaching file.

    'File path is not in temporary directory' 
    
    Where is the tmp file?
    

     

    THANKS!!

    Version:
    may 2012
    Code Snippet:

    Comment

    • Patricia Harvath

      From my email archive:

      The contents of the file are dynamic, so I don't know how to answer your question.  The 'contents' of these files is the word TEXT.  How do you strip a file of it's content?
      
      My apologies if this should be evident.
      
    • Christopher Sanderson

      Allan, unfortunately it really was Patricia's last day.  If you have any updates or advice that you might have sent her, can you repost for me?

       

      Thanks!

      Christopher

    • Allan Schrum

      Hi Christopher,

      I made some replies to the posting via email but it looks like they did not properly show up. I shall see if I can find the original messages and update this conversation. Then we can continue where Patricia left off.

      Regards,

      -Allan

    • Allan Schrum

      So I have updated the postings. Patricia, if you see an error or a correction that is needed please let me know.

      The idea is to get the contents of the file into the temporary file of the file attachments so that it can be saved. If you know where the file is on the system, then you can use the first method (see way above) to identify it. Otherwise, you must use file I/O to copy the contents into the temporary file created by the makeFile method.

      Take a look at where Patricia left off and see if we can get this completed.

      Regards,

      -Allan

    • James Hurster

      Hello Allan,

      I have taken over the roll of Web Developer that Patricia held and am now diving into this case.  I will start off by saying I am new to RN but not web development.  Though I have a background in Web Dev it appears RN is a whole other beast :) !

      I just want to make something clear before I try to troubleshoot this situation.  In reading the posts it was never mentioned before (That I know of).  The functionality of the FileAttachmentUpload2 widget works great on our main ask page with this widget code:

      <rn:widget path="input/FileAttachmentUpload2"/>

      The page Patricia was trying to get it to work on has slightly different code and the page is in a newly created directory "views/pages/cs/".  Also the code that the widget is using on the new page in the new directory "cs" is 

      <rn:widget path="standard/input/FileAttachmentUpload2" />


      So I wanted to clear that up before I got an answer from you to see if maybe any of this information would make things easier.  While I wait for your reply, I will start looking into some of the suggestions and see if I can get somewhere.

      Side Note:  This is also the case on many of our other interfaces.  All of the functionality works great on the main ask.php page but when there is a new folder created and page within it calls this widget, all *** breaks loose! smiley

      Thanks for helping!

      - James

    • Allan Schrum

      Hi James,

      Since this involves CP I'd like to have a CP team member look at this issue as well. It would help if we new what version of Customer Portal you are using. The older CPv2 had different methods for dealing with file attachments.

      Regards,

      -Allan

    • James Hurster

      Sure Allan,

      Sorry for not stating that (I guess it too was never mentioned) smiley.

      We are on CP2, May 2012

      Thanks!

      - James

    • Jeremy Watson

      James,

      Where does this Connect file attachment code exist?  Can you include the full file and/or function?

      James

    • James Hurster

      James,

      That is a good question that I am not certain I have the answer to (regarding the PHP Connect).  My goal is to get back to best practices.  I am attaching the page that is having the issues.  In addition I am giving you this URL where the page is:

      https://enterprise-int.custhelp.com/app/cs/citation_0101

      I am more than happy to send you anything you think you may need to get this figured out.  Also please keep in mind that on our main ask page:

      https://enterprise-int.custhelp.com/app/ask

      we have no problems.  It works great.  However the citation file lives in a new directory and I have noticed a fair amount of custom code on the file.

      I apologize for not knowing more about this situation.  I have inherited this and am trying to figure out as much as I go with the help of you guys which I appreciate tremendously.  Feel free to get back at me with anything else you need.

      Finally, I think it is worth noting that the citations page is submitting fine however any file that is uploaded is somehow given the content of the original file that was uploaded way back when.  So to clarify, I could upload a file that says "James is the coolest name on the face of the earth".  But when I am in the console and I open the incident, the text that shows up is always "This is the contents of a text file".  I am told this was the test text that was used on the very first test run that worked... now they all say this...

      Thanks!

      - James

    • Jeremy Watson

      This may be a little awkward to diagnose through the forums, so you may get better help through Customer Care, since they'll be able to easily review your site and step you through possible issues, but I'll try and help as much as I can.

      When you upload a file, you should see a request being made to the server (use Fiddler2, Firebug in Firefox, or the Developer Tools in Chrome to see the request).  Usually it is something like '/ci/fattach/upload', but I suspect that it might be something different in your case.  Can you tell me what the path is?  That might help lead us to where 'This is the contents of a text file' is appearing.

      Also, when you submit the form (not just upload the file), what does the request look like?  It should usually be '/ci/ajaxRequest/sendForm', but I'm wondering if yours is also something custom.

      James

    • James Hurster

      [13:12:39.979] POST http://enterprise-int.custhelp.com/ci/fattach/upload [HTTP/1.1 200 OK 569ms]

      That is what I got from the file upload... More to come on the submission request.  

    • James Hurster

      Here is a screenshot.  thanks James!

       

       

    • Jeremy Watson

      Okay, that's helpful.  Look in your custom controller (controllers/ajaxCustom.php) for the function sendFormAsk_CS0101.  I wouldn't be surprised if you see the file text in that function.  Either way, feel free to post that function here and maybe I can take a look at it.

      James

    • James Hurster

      Here is the code I think you are looking for.  You have been a great help.  I have not had the chance to dive into RN this extensively so thanks again for your time.

       

       

      function sendFormAsk_CS0101()
          {
              AbuseDetection::check($this->input->post('f_tok'));
              $data = json_decode($this->input->post('form'));
              if(!$data)
              {
                  writeContentWithLengthAndExit(json_encode(getMessage(JAVASCRIPT_ENABLED_FEATURE_MSG)));
              }
              $incidentID = $this->input->post('i_id');
      $cont_id = $this->input->post('c_id');
       
      $org_id = 13;
      $CI = &get_instance();
      $CI->session->setSessionData(array('cont_id'=>$cont_id));
       
       //       $smartAssistant = $this->input->post('smrt_asst');
         $serviceCat_id = $this->input->post('serviceCat_id');
      $citNumDiv = $this->input->post('citNumDiv');
              $adminDiv = $this->input->post('adminDiv');
        $citDiv = $this->input->post('citDiv');
      $totalRefundDiv = $this->input->post('totalRefundDiv');
      $issueDate = $this->input->post('datepicker');
      $issueDate = strtotime($issueDate);
       
      //Check for a citation number... if there is one, add data. 
      //If there isn't one, create a new one....
       
      $res = RNCPHP\ROQL::queryObject("SELECT CS_Cit_0100.CitationNumber FROM CS_Cit_0100.CitationNumber WHERE CS_Cit_0100.CitationNumber.CitNumber ='".$citNumDiv."'");
      while($cit = $res->next())
      {
      while ($row = $cit->next())
      {
      $citDup = $row->ID;
       
      }
      }
       
      //Creating new Citation 
      $citdata = new RNCPHP\CS_Cit_0100\Citation();
      $citdata->IsCreated = true;
      $citdata->save();
      $citdataID = $citdata->ID;
      //Create the new Citation Number - $citNum;
      $cndata = new RNCPHP\CS_Cit_0100\CitationNumber();
      $cndata->CitNumber = $citNumDiv;
      $cndata->Citation = $citdataID;
      if($issueDate){
      $cndata->CitationIssueDate = $issueDate;
      }
      if($citDup){
      $cndata->DuplicateCitationNumber = "Yes";
      }
      $cndata->save();
      $cndataID = $cndata->ID;
       
      //Create the new fee record for the $citNum;
      $adminAmt = array();
      $adminAmt = explode(' ' , $this->input->post('adminDiv'));
      $adminAmt = ($adminAmt[1] * 100);
       
      $refundAmt = array();
      $refundAmt = explode(' ' , $this->input->post('totalRefundDiv'));
      $refundAmt = ($refundAmt[1] * 100);
       
      $citAmt = array();
      $citAmt = explode(' ' , $this->input->post('citDiv'));
      $citAmt = ($citAmt[1] * 100);
       
      $cfdata = new RNCPHP\CS_Cit_0100\CitationFee();
      $cfdata->CitationNumber = $cndataID;
      $cfdata->TotalRefund = $refundAmt;
      $cfdata->AdminFee = $adminAmt;
      $cfdata->CitationAmount = $citAmt;
      $cfdata->save();
       
        $this->load->model('custom/Cs0100_field_model');
             $results = $this->Cs0100_field_model->sendForm_CS0101($data, $incidentID, $citdataID, $serviceCat_id);
          echo json_encode($results);
         }
    • Jeremy Watson

      Okay, we might be getting closer.  How about the sendForm_CS0101 function in your custom model (models/custom/Cs0100_field_model.php)?  That is what is being called on the second to last line of the function.

      James