Root > Integral parts > Send engines > HTTP upload

HTTP upload

Previous pageReturn to chapter overviewNext page   

HTTP send method uploads bug report via HTTP protocol to web server. It uses HTTP POST method. I.e. it's very similar to filling a form on web page and clicking on "Submit" button. In order to work, this method requires special script on web server side, which will receive bug reports.

 

During HTTP send, EurekaLog sends bug report and additional files (if specified) as standard upload. For example, you can use the following PHP script, which uses standard $_FILES array to process uploaded files:

 

<?php
 
  foreach($_FILES as $key=>$value)
  {
   $uploaded_file = $_FILES[$key]['tmp_name'];

   // Writable folder:
   $server_dir = 'C:\\upload\\'// example for Windows
// $server_dir = 'upload/';  // example for *nix 
   $server_file = $server_dir.basename($_FILES[$key]['name']);
 
    // Move the uploaded file to the Server uploaded directory...
    if (move_uploaded_file($uploaded_file, $server_file))
    {
      // Here is your code...
      // You can process uploaded files here, if you want/need to
    }
  }
 
?>

 

You can place this code to .php file (like upload.php) and place this file to your web server (like http://example.com/upload.php), and then specify this URL in HTTP send options (without "http://").

 

Warning: be sure to setup adequate maximum upload file limits in your web-server/script configuration. Otherwise sending may fail on large bug reports.

 

You can also provide additional data via OnCustomWebFieldsRequest event handler. For example, assign such event hanlder:

 

uses
  EEvents;
 
procedure AddApplicationName(const ACustom: Pointer; AExceptionInfo: TEurekaExceptionInfo; 
  ASender: TObject { TELWebSender }; AWebFields: TStrings; var ACallNextHandler: Boolean);

begin
  AWebFields.Values['Application'] := AnsiLowerCase(ExtractFileName(ParamStr(0)));
end;
 
initialization
  RegisterEventCustomWebFieldsRequest(nil, AddApplicationName);
end.

 

Then, you can access your new "Application" field from your script. For PHP it will be $_REQUEST["Application"] or $_POST["Application"].

 

You don't have to use PHP. You can use script on any other scripting language (like ASP.NET). The above code is just simple example. The point is that such upload is standard file upload, there is no default functionality to handle it, so you need to write some code to handle it. How you do that, what amount of work you'll do - it's up to you.

 

See also examples below for more advanced script usage.

 

 

Advantages:

Simple setup.
Highly customizable.
Little chances to be blocked by firewall (almost everybody have internet access, which means HTTP access).
Can deliver backward feedback (via custom scripts).
SSL/TLS support.

 

Drawbacks:

No bug report management (by default).
User e-mail address is optional.
A lot of custom work to get anything above basic upload functionality.
Requires hosting or HTTP server.

 

Currently EurekaLog supports only HTTP Basic-AUTH (basic access authentication) authentication method.

 

You can test any of your scripts by using HTML page on your web server (say, test.htm file):

 

<html>
  <body>
    <form enctype="multipart/form-data" action="upload.php" method="POST">
      <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
      Send this file: <input name="userfile" type="file" />
      <input type="submit" value="Send File" />
    </form>
  </body>
</html>

 

(of course, you must replace "upload.php" with your data; you don't have to place this page on web server, you can run it locally - in this case action parameter will be like this: action="http://example.com/upload.php")

 

You can also add some debugging output to your scripts. For example (this is modified example of the PHP script above):

 

<?php
 
  foreach($_FILES as $key=>$value) 
  { 
    $uploaded_file = $_FILES[$key]['tmp_name']; 
    $server_dir = 'c:\\writable\\';
    $server_file = $server_dir . basename($_FILES[$key]['name']); 
 
    echo $uploaded_file; 
    echo $server_file; 
 
    if (move_uploaded_file($uploaded_file, $server_file)) 
    { 
      echo 'Ok'
    } 
    else 
    { 
      echo 'Fails'
    } 
 
  }  
 
?>

 

Just don't forget to remove debug code before real using!

 

It's also possible to get a feedback from upload script. Script can set custom message to show and upload status (like "OK", "error" and "bug fixed"). It's done by generating a HTML output with special tags. Currently, EurekaLog supports only 2 tags out-of-the-box: EurekaLogStatus and EurekaLogReply. To use these tag, you must generate a HTML in your script like this:

 

<?php
 
  foreach($_FILES as $key=>$value) 
  { 
    $uploaded_file = $_FILES[$key]['tmp_name']; 
    $server_dir = 'c:\\writable\\';
    $server_file = $server_dir . basename($_FILES[$key]['name']); 
 
    move_uploaded_file($uploaded_file, $server_file);
 
  }  
 

  echo '<html>';

  echo '<head>';

  echo '<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">';

  echo '<title>Bug submission</title>';

  echo '</head>';

  echo '<body>';

  echo 'Thank you!<br />';   

  echo '</body>';

  echo '</html>';
?>

 

And you can add these two tags in any place inside this HTML. You can enclose these tags in comments to prevent them from appearing in HTML itself, for example:

 

<?php

 

  foreach($_FILES as $key=>$value) 

  { 

    $uploaded_file = $_FILES[$key]['tmp_name']; 

    $server_dir = 'c:\\writable\\';

    $server_file = $server_dir . basename($_FILES[$key]['name']); 

 

    move_uploaded_file($uploaded_file, $server_file);

 

  }  

?>

<html>

  <head>

    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">

    <title>Bug submission</title>

  </head>

<body>

<!-- 

 

Place here any EurekaLog-specific tags

 

<EurekaLogReply>Thank you for your feedback!</EurekaLogReply>

 

-->

 

Thank you!<br />   

</body>

</html>

<?php

 
?>

 

EurekaLogStatus tag must contain an integer value, which represents operation status (TSendResult type). Most typically used values are srSent, srBugClosed, srInvalidInsert and srUnknownError. srSent and srBugClosed are considered as success status. All other codes are considered as failure. If this tag isn't used, the srSent is the default.

 

Note: it's important to use numeric value (like, '0', '1', '$1'), not name itself (like 'srSent').

 

You can use this tag to alter status of sending, but usually you omit this tag.

 

EurekaLogReply tag contains arbitrary string, which will be used as custom message, describing the operation. If this tag isn't used, the message will be empty. If status of the operation is the success (srSent or srBugClosed), then this message will appear in SuccessMessage field of TResponse record. If status is failure - message will appear in ErrorMessage field.

 

Alternatively, you can insert a http:// or https:// link into message. In this case EurekaLog will open a web-browser for this link without showing any other message. Showing HTML page can be used to present "pretty" message, detailed instructions or other advanced messages. For example, if "bug" is not a bug in your software, but problem in run-time configuration, you can insert the URL to your knowledge base article, which describes solution. Another example - you can't solve bug with existing bug report's information. Thus, you close bug and use an URL to web-page, where you ask user to submit more information.

 

For example:

 

<?php

 

// place any initialization code here

 

?>

 

<html>

  <head>

    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=UTF-8">

    <title>Bug submission</title>

  </head>

<body>

Thank you!<br />   

 

<!-- 

 

<?php

 

  $fail = TRUE;

  $newbug = TRUE;

 

  foreach($_FILES as $key=>$value) 

  { 

    $uploaded_file = $_FILES[$key]['tmp_name']; 

    $server_dir = 'c:\\writable\\';

    $server_file = $server_dir . basename($_FILES[$key]['name']); 

 

    echo 'Submitted: ' . basename($_FILES[$key]['name']) . '<br />';

   

    if (!move_uploaded_file($uploaded_file, $server_file))

      break;

    else

      $fail = FALSE;

 

  }  

 

  if ($fail) 

  {

    echo '<EurekaLogStatus>$8000FFFF</EurekaLogStatus>';

    echo '<EurekaLogReply>Sorry, something goes wrong! Please, report this to admin@example.com</EurekaLogReply>';

  }

  else

  {

 

    // <- here: determine if uploaded file(s) contains already fixed bug or not; set $newbug for check's result

 

    if ($newbug) 

    {

      echo '<EurekaLogStatus>0</EurekaLogStatus>';

      echo '<EurekaLogReply>Thank you for your feedback! We will try to fix this as soon as possible!</EurekaLogReply>';

    }

    else

    {

      echo '<EurekaLogStatus>1</EurekaLogStatus>';

      echo '<EurekaLogReply>Thank you for your feedback! This error was already fixed! ';

      echo 'Please, go to www.example.com and download a new version.</EurekaLogReply>';

    }

  }

 

?>

 

-->

 

</body>

</html>

 

<?php

 

// place any finalization code here

 
?>

 

See also: customizing feedback.

 

Note: remember - you don't have to use PHP. PHP is selected only as example language. You can write receiver-script in any language: ASP, .NET, (Win)CGI, etc. Just handle the standard file uploads and return some HTML page. That's all.

 

For example, you can use FogBugz anonymous report page as HTTP form to receive EurekaLog reports. You can also use Jira's issue collector.

 

Constant: wsmHTTP.

 

 

See also:




Send feedback... Build date: 2024-09-30
Last edited: 2023-07-18
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/http_upload.php