Filename of uploaded images

I can see a couple of posts that have already been made about the filename used in the "Save As" dialog box after clicking on a FileDownload link but I can't see a resolution being supplied for this.
I am using JHeadstart 10.1.2.0 and JDeveloper 10.1.2.0.0.
I have created a table with im_orddoc ordsys.orddoc, filename varchar2(100).
In my view object I created a transient attribute to be used as the file download. Within the JHeadstart property editor, the im_orddoc is set to displayType of fileUpload and File Name Attribute to Filename. The transient download_orddoc is set to displayType of fileDownload and File Name Attribute to Filename.
The filename is being stored correctly and being displayed correctly as the file download link, only, when you click on the link, in the file download box (using IE), the file name reverts to "ordDeliverMedia.xxx".
How can I get the correct filename to be displayed in the save as dialog box instead of this generic name ?
Also, I want to be able to display a link within a form for all types of uploaded media (ie doc, exel, jpg etc...). If an image has not been uploaded, a link is displayed. If an image has been uploaded, then the image is rendered rather than a link. How can I ensure that a link is always shown regardless of media type ?
Cheers,
Brent Harlow

Brent,
Yes, we noticed this too. Both issues are caused by the "magic" of the UIX <media> tag. It automatically recognizes the file type and displays an image as image instead of download link (a user can still right-mouse-click on the image and choose Save as..."). The issue with the filename in the download box is probably a combination of <media> tag and IE, in Firefox it works fine. Could you please repost your questions on the JDeveloper forum, may be the UIX guys know of additional settings on the <media> element to get the behavior you want.
Steven Davelaar,
JHeadstart Team.

Similar Messages

  • Upload image to directory and data to database from the same form

    Hello all
    I'm playing at building a shopping cart (never done one
    before) from a tutorial by Gordon Knapp at www.webthang.com.
    I have created the site and it works perfectly. Now I want to
    extend it.
    There is a form that allows the user to add data to the
    database. I would also like to be able to upload an image to a
    directory on the server and add the data to the database at the
    same time from the same form. It would be good if the input field
    "<input name="product_picture" type="text" id="product_picture"
    tabindex="6" size="50" />" could be populated automatically by
    the filename of the image being uploaded, but this isn't a
    neccessity.
    I have looked at various ASP Upload packages and I can upload
    an image alone but none of them make it clear how to upload the
    image and add data to the database at the same time.
    As this is a private project I need any suggestions to by
    free.
    The tutorial shows how to create the site in Ultra Dev but
    worked perfectly well in DW. The page concerned looks like this. It
    is named 'admin_add.asp':
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!--#include file="../Connections/con_ecom.asp" -->
    <%
    Dim MM_editAction
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
    MM_editAction = MM_editAction & "?" &
    Server.HTMLEncode(Request.QueryString)
    End If
    ' boolean to abort record edit
    Dim MM_abortEdit
    MM_abortEdit = false
    %>
    <%
    ' IIf implementation
    Function MM_IIf(condition, ifTrue, ifFalse)
    If condition = "" Then
    MM_IIf = ifFalse
    Else
    MM_IIf = ifTrue
    End If
    End Function
    %>
    <%
    If (CStr(Request("MM_insert")) = "add_form") Then
    If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd
    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_con_ecom_STRING
    MM_editCmd.CommandText = "INSERT INTO products
    (product_category, product_name, product_price, product_briefdesc,
    product_fulldesc, product_picture) VALUES (?, ?, ?, ?, ?, ?)"
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param1", 202, 1, 50,
    Request.Form("product_category")) ' adVarWChar
    MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param2", 202, 1, 50,
    Request.Form("product_name")) ' adVarWChar
    MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param3", 5, 1, -1,
    MM_IIF(Request.Form("product_price"),
    Request.Form("product_price"), null)) ' adDouble
    MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param4", 203, 1, 536870910,
    Request.Form("product_briefdesc")) ' adLongVarWChar
    MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param5", 203, 1, 536870910,
    Request.Form("product_fulldesc")) ' adLongVarWChar
    MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param6", 202, 1, 50,
    Request.Form("product_picture")) ' adVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close
    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "admin_control.asp"
    If (Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0)
    Then
    MM_editRedirectUrl = MM_editRedirectUrl & "?" &
    Request.QueryString
    Else
    MM_editRedirectUrl = MM_editRedirectUrl & "&" &
    Request.QueryString
    End If
    End If
    Response.Redirect(MM_editRedirectUrl)
    End If
    End If
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Administration - Add Product</title>
    <link href="../scripts/admin.css" rel="stylesheet"
    type="text/css" />
    <script type="text/javascript"
    src="../scripts/ecom.js"></script>
    </head>
    <body onLoad="adminTitle()">
    <div id="wrapper">
    <div id="pageHeading">ADMINISTRATION - ADD
    PRODUCT</div>
    <div id="navBar"><a
    href="admin_control.asp">Control</a> | Add | <a
    href="admin_view.asp">View</a> | <a
    href="admin_update1.asp">Update</a> | <a
    href="admin_delete1.asp">Delete</a> | <a
    href="../Default.asp">Shop</a></div>
    <br />
    <form name="add_form" id="add_form" method="POST"
    action="<%=MM_editAction%>">
    <table border="1" align="center" id="tblArea">
    <tr>
    <td class="tdLabel">Product Category</td>
    <td colspan="2"><input name="product_category"
    type="text" id="product_category" tabindex="1" size="50"
    /></td>
    </tr>
    <tr>
    <td class="tdLabel">Product Name</td>
    <td colspan="2"><input name="product_name"
    type="text" id="product_name" tabindex="2" size="50"
    /></td>
    </tr>
    <tr>
    <td class="tdLabel">Product Price</td>
    <td class="tdContent" colspan="2"><input
    type="text" name="product_price" id="product_price" tabindex="3"
    size="50" /></td>
    </tr>
    <tr>
    <td class="tdLabel">Product Short
    Desciption</td>
    <td class="tdContent" colspan="2"><textarea
    name="product_briefdesc" id="product_briefdesc" cols="47" rows="4"
    tabindex="4"></textarea></td>
    </tr>
    <tr>
    <td class="tdLabel">Product Full
    Description</td>
    <td class="tdContent" colspan="2"><textarea
    name="product_fulldesc" id="product_fulldesc" cols="47" rows="5"
    tabindex="5"></textarea></td>
    </tr>
    <tr>
    <td class="tdLabel">Product Image File Name</td>
    <td class="tdContent" colspan="2"><input
    name="product_picture" type="text" id="product_picture"
    tabindex="6" size="50" /></td>
    </tr>
    <tr>
    <td class="tdLabel"> </td>
    <td align="center"><input type="reset" name="Reset"
    id="Reset" value="Reset Form" /></td>
    <td align="center"><input type="submit"
    name="Submit" id="Submit" value="Add To Shop" /></td>
    </tr>
    </table>
    <input type="hidden" name="MM_insert" value="add_form"
    />
    </form>
    </div>
    </body>
    </html>
    Hope you can help.
    Warm regards
    Martin

    Got it sorted.
    Found an excellent tutorial at Webthang.
    http://www.webthang.co.uk/tuts/tuts_dmx/rob15/rob15.asp

  • Problem when trying to rename uploaded images using session value

    Hi,
    I have a form where 9 images are uploaded made into thumb nail size and then stored in a file. What I´m trying to do is rename those thumbnails from their original name to username_0, username_1, username_2 etc for each of the 9 thumbs. The username comes from the registration form on the same page. I have created a session variable for the username and am trying to use that to change to name of the image name, whilst my images are uploading and resizing the name stays as the original and not as the new username_$number. I have pasted relevant code below and would very much appreciate any help with this:
    <?php session_start();
    // check that form has been submitted and that name is not empty and has no errors
    if ($_POST && !empty($_POST['directusername'])) {
    // set session variable
    $_SESSION['directusername'] = $_POST['directusername'];
    // define a constant for the maximum upload size
    define ('MAX_FILE_SIZE', 5120000); 
    if (array_key_exists('upload', $_POST)) {
    // define constant for upload folder
    define('UPLOAD_DIR', 'J:/xampp/htdocs/propertypages/uploads/');
    // convert the maximum size to KB
    $max = number_format(MAX_FILE_SIZE/1024, 1).'KB';
    // create an array of permitted MIME types
    $permitted = array('image/gif','image/jpeg','image/pjpeg','image/png');
    foreach ($_FILES['photo']['name'] as $number => $file) {
    // replace any spaces in the filename with underscores
    $file = str_replace(' ', '_', $file);
    // begin by assuming the file is unacceptable
    $sizeOK = false;
    $typeOK = false;
    // check that file is within the permitted size
    if ($_FILES['photo']['size'] [$number] > 0 && $_FILES['photo']['size'] [$number] <= MAX_FILE_SIZE) {
    $sizeOK = true;
    // check that file is of a permitted MIME type
    foreach ($permitted as $type) {
    if ($type == $_FILES['photo']['type'] [$number]) {
    $typeOK = true;
    break;
    if ($sizeOK && $typeOK) {
    switch($_FILES['photo']['error'] [$number]) {
    case 0:
    include('Includes/create_thumbs.inc.php');
    break;
    case 3:
    $result[] = "Error uploading $file. Please try again.";
    default:
    $result[] = "System error uploading $file. Please contact us for further assistance.";
    elseif ($_FILES['photo']['error'] [$number] == 4) {
    $result[] = 'No file selected';
    else {
    $result[] = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png.";
    ................CODE BELOW IS THE INCLUDES FILE THAT MAKES AND TRIES TO RENAME THE THUMBS................................................
    <?php
    // define constants
    define('THUMBS_DIR', 'J:/xampp/htdocs/propertypages/uploads/thumbs/');
    define('MAX_WIDTH_THB', 75);
    define('MAX_HEIGHT_THB', 75);
    set_time_limit(600);
    // process the uploaded image
    if (is_uploaded_file($_FILES['photo']['tmp_name'][$number] )) {
    $original = $_FILES['photo']['tmp_name'][$number] ;
    // begin by getting the details of the original
    list($width, $height, $type) = getimagesize($original);
    // check that original image is big enough
    if ($width < 270 || $height < 270) {
    $result[] = 'Image dimensions are too small, a minimum image of 270 by 270 is required';
    else { // crop image to a square before resizing to thumb
    if ($width > $height) {
    $x = ceil(($width - $height) / 2);
    $width = $height;
    $y = 0;
    else if($height > $width) {
    $y = ceil(($height - $width) / 2);
    $height = $width;
    $x = 0;
    // calculate the scaling ratio
    if ($width <= MAX_WIDTH_THB && $height <= MAX_HEIGHT_THB) {
    $ratio = 1;
    elseif ($width > $height) {
    $ratio = MAX_WIDTH_THB/$width;
    else {
    $ratio = MAX_HEIGHT_THB/$height;
    if (isset($_SESSION['directusername'])) {
    $username = $_SESSION['directusername'];
    // strip the extension off the image filename
    $imagetypes = array('/\.gif$/', '/\.jpg$/', '/\.jpeg$/', '/\.png$/');
    $name = preg_replace($imagetypes, '', basename($_FILES['photo']['name'][$number]));
    // change the images names to the user name _ the photo number
    $newname = str_replace ('name', '$username_$number', $name);
    // create an image resource for the original
    switch($type) {
    case 1:
    $source = @ imagecreatefromgif($original);
    if (!$source) {
    $result = 'Cannot process GIF files. Please use JPEG or PNG.';
    break;
    case 2:
    $source = imagecreatefromjpeg($original);
    break;
    case 3:
    $source = imagecreatefrompng($original);
    break;
    default:
    $source = NULL;
    $result = 'Cannot identify file type.';
    // make sure the image resource is OK
    if (!$source) {
    $result = 'Problem uploading image, please try again or contact us for further assistance';
    else {
    // calculate the dimensions of the thumbnail
    $thumb_width = round($width * $ratio);
    $thumb_height = round($height * $ratio);
    // create an image resource for the thumbnail
    $thumb = imagecreatetruecolor($thumb_width, $thumb_height);
    // create the resized copy
    imagecopyresampled($thumb, $source, 0, 0, $x, $y, $thumb_width, $thumb_height, $width, $height);
    // save the resized copy
    switch($type) {
    case 1:
    if (function_exists('imagegif'))  {
    $success[] = imagegif($thumb, THUMBS_DIR.$newname.'.gif');
    $photoname = $newname.'.gif';
    else {
    $success[] = imagejpeg($thumb, THUMBS_DIR.$newname.'.jpg',50);
    $photoname = $newname.'.jpg';
    break;
    case 2:
    $success[] = imagejpeg($thumb, THUMBS_DIR.$newname.'.jpg', 100);
    $photoname = $newname.'.jpg';
    break;
    case 3:
    $success[] = imagepng($thumb, THUMBS_DIR.$newname.'.png');
    $photoname = $newname.'.png';
    if ($success) {
    $result[] = "Upload sucessful";
    else {
    $result[] = 'Problem uploading image, please try again or contact us for further assistance';
    // remove the image resources from memory
    imagedestroy($source);
    imagedestroy($thumb);
    ?>
    I hope i´ve supplied enough information and look forward to receiving any help or advise in this matter.

    Use double quotes here:
    $newname = str_replace ('name', '$username_$number', $name);
    Change it to this:
    $newname = str_replace ('name', "$username_$number", $name);

  • Storing Uploaded Image Path into Mysql

    Hi I am developing a cms and am using the code David gives in his book PHP Solutions,  everything works fine but I can't work out how to extract the uploaded path so that it is stored in my table.
    Help would be really appreciated, I am making good progress in learning the php especially with David's books but am still struggling when it comes to having to customized the code.
    The code for the upload.php is as follows,
    <?php
    class Gp1_Upload{
      protected $_uploaded = array();
      protected $_destination;
      protected $_max = 51200;
      protected $_messages = array();
      protected $_permitted = array('image/gif',
                                    'image/jpeg',
                                    'image/pjpeg',
                                    'image/png');
      protected $_renamed = false;
      public function __construct($path) {
        if (!is_dir($path) || !is_writable($path)) {
          throw new Exception("$path must be a valid, writable directory.");
        $this->_destination = $path;
        $this->_uploaded = $_FILES;
      public function getuploadpath (){
      public function getMaxSize() {
        return number_format($this->_max/1024, 1) . 'kB';
      public function setMaxSize($num) {
        if (!is_numeric($num)) {
          throw new Exception("Maximum size must be a number.");
        $this->_max = (int) $num;
      public function move($overwrite = false) {
        $field = current($this->_uploaded);
        if (is_array($field['name'])) {
          foreach ($field['name'] as $number => $filename) {
            // process multiple upload
            $this->_renamed = false;
            $this->processFile($filename, $field['error'][$number], $field['size'][$number], $field['type'][$number], $field['tmp_name'][$number], $overwrite);   
        } else {
          $this->processFile($field['name'], $field['error'], $field['size'], $field['type'], $field['tmp_name'], $overwrite);
      public function getMessages() {
        return $this->_messages;
      protected function checkError($filename, $error) {
        switch ($error) {
          case 0:
            return true;
          case 1:
          case 2:
            $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
            return true;
          case 3:
            $this->_messages[] = "Error uploading $filename. Please try again.";
            return false;
          case 4:
            $this->_messages[] = 'No file selected.';
            return false;
          default:
            $this->_messages[] = "System error uploading $filename. Contact webmaster.";
            return false;
      protected function checkSize($filename, $size) {
        if ($size == 0) {
          return false;
        } elseif ($size > $this->_max) {
          $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
          return false;
        } else {
          return true;
      protected function checkType($filename, $type) {
        if (empty($type)) {
          return false;
        } elseif (!in_array($type, $this->_permitted)) {
          $this->_messages[] = "$filename is not a permitted type of file.";
          return false;
        } else {
          return true;
      public function addPermittedTypes($types) {
        $types = (array) $types;
        $this->isValidMime($types);
        $this->_permitted = array_merge($this->_permitted, $types);
      protected function isValidMime($types) {
        $alsoValid = array('image/tiff',
                           'application/pdf',
                           'text/plain',
                           'text/rtf');
          $valid = array_merge($this->_permitted, $alsoValid);
        foreach ($types as $type) {
          if (!in_array($type, $valid)) {
            throw new Exception("$type is not a permitted MIME type");
      protected function checkName($name, $overwrite) {
        $nospaces = str_replace(' ', '_', $name);
        if ($nospaces != $name) {
          $this->_renamed = true;
        if (!$overwrite) {
          $existing = scandir($this->_destination);
          if (in_array($nospaces, $existing)) {
            $dot = strrpos($nospaces, '.');
            if ($dot) {
              $base = substr($nospaces, 0, $dot);
              $extension = substr($nospaces, $dot);
            } else {
              $base = $nospaces;
              $extension = '';
            $i = 1;
            do {
              $nospaces = $base . '_' . $i++ . $extension;
            } while (in_array($nospaces, $existing));
            $this->_renamed = true;
        return $nospaces;
      protected function processFile($filename, $error, $size, $type, $tmp_name, $overwrite) {
        $OK = $this->checkError($filename, $error);
        if ($OK) {
          $sizeOK = $this->checkSize($filename, $size);
          $typeOK = $this->checkType($filename, $type);
          if ($sizeOK && $typeOK) {
            $name = $this->checkName($filename, $overwrite);
            $success = move_uploaded_file($tmp_name, $this->_destination . $name);
            if ($success) {
                $message = "$filename uploaded successfully";
                if ($this->_renamed) {
                  $message .= " and renamed $name";
                $this->_messages[] = $message;
            } else {
              $this->_messages[] = "Could not upload $filename";
    ?>
    The code for my form page is this
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <?php
    //THE FOLLOWING CODE IS FOR THE UPLOADING OF IMAGES AND FILES
    // set the max upload size in bytes
    $max = 51200;
    if (isset ($_POST ['submit']))
                //define the path to the upload folder
                $destination = 'uploads/';
                require_once('classes/Upload.php');
                try {
                    $upload = new Gp1_Upload($destination);
                    $upload->setMaxSize($max);
                    $upload->move();
                    $result = $upload->getMessages();
                } catch (Exception $e) {
                    echo $e->getMessage();
    // END OF UPLOADING OF IMAGES AND FILES
    ?>
    <form id="newvenue" action="" method="post" enctype="multipart/form-data" >
          <?php
               // THIS CODE DISPLAYS ERROR MESSAGES FOR THE FILE UPLOADS
              if (isset($result)){
              echo '<ul>';
              foreach ($result as $message){
                  echo "<li>$message</li>";
              echo '</ul>';
           ?>
      <table id="neweventdisplay" cellpadding="5"  border="0">
        <tr>
      <td></td>
      <td><input type="hidden" name="user_id"  value="" /></td>
      </tr>
      <tr>
      <td></td>
        <td>Organisers Name</td>
        <td><input class="input80px" id="org_name" name="org_name" type="text" /> </td>
      </tr>
      <tr>
      <td></td>
      <td><label for="image">Upload image:</label></td>
      <td><p>
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>" />
    <input type="file" name="image" id="image" />
    </p></td>
    </tr>
      <tr>
      <td></td>
      <td>Details about your upload</td>
      <td><input class="input80px" id="org_uploadcapt" name="org_uploadcapt" type="text"  /></td>
    </tr>
      <tr>
      <td></td>
      <td><input type="submit" name="submit" id="submit" value="upload"></td>
      </tr>
      <tr>
      <td class="heading"> </td>
      <td></td>
      </tr>
    </table>
    </form>
    <prep>
    <?php
    if (isset ($_POST ['submit'])){
        print_r($_FILES);}
        ?>
        </prep>
    </body>
    </html>

    Hi David
    Thank you very much for your help.  I had continued to work on the code and had worked out how to input the image path into the database but it was using the original filename, so when every it is changed it did not work.  The code in my page at that point was the following,
    <?php     // 2. NEW USER REGISTRATION<br />
            include_once ("includes/form_functions.inc.php");
            $max = 100000;
            $destination = 'uploads/';
            // START FORM PROCESSING FOR A NEW REGISTRATION
            if (isset($_POST['submit'])) { // Form has been submitted.
            $errors = array();
            // perform validations on the form data
            $required_fields = array('org_name');
            $errors = array_merge($errors, check_required_fields($required_fields, $_POST));    
            $required_numberfields = array('user_id');
            $errors = array_merge($errors, check_number_fields($required_numberfields, $_POST));
            $fields_with_lengths = array('org_name' => 36, 'org_website' => 100, 'org_contact' => 40,  'org_conemail' => 80, 'org_contel' => 30);
            $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST));
            /*Here I am using trim as well as ucwords, this function converts the first letter of each work into a capital letter,  I am using this only on the
            firstname and surname to ensure that the data is how I want it as it is going  into the database,  The better the data is preformated the better the data
            swill be within the database.*/
            $org_name = trim(strtolower(mysql_prep($_POST['org_name'])));
            $org_website = trim(strtolower(mysql_prep($_POST['org_website'])));
            $org_contact = trim(strtolower (mysql_prep($_POST['org_contact'])));
            $org_conemail = trim(strtolower (mysql_prep($_POST['org_conemail'])));
            $org_contel = strtolower (mysql_prep($_POST['org_contel']));
            $userid = $_POST['user_id'];
            $org_uploadcapt = $_POST['org_uploadcapt'];
            $image = $_FILES['image'];
            /*Here is the code that takes the variable captured from the input form and matches it  up with the appropriate field in the database.  An important point with insertion is that  the variables are in the same order as the mysql field names, there will be an error if the number of variables does not match the number of field names.  Note that there is no entry for the user id as this is an auto increment file within mysql and so is not needed to be entered*/
            if ( empty($errors) ) {
                $sql = "INSERT INTO organiser
                          (org_name, org_website, org_contact, org_conemail, org_contel, user_id, org_uploadurl, org_uploadcapt)
                          VALUES
                          ('{$org_name}', '{$org_website}', '{$org_contact}', '{$org_conemail}', '{$org_contel}', '{$userid}', '{$destination}".$image['name']."', '{$org_uploadcapt}' )";
                $result = mysql_query($sql, $connection);
                if ($result) {
                    $message = "The organiser was successfully created.<br />";
                } else {
                    $message = "I am sorry but the organiser could not be added.";
                    $message .= "<br />" . mysql_error();
                } else {
                    /* this counts the number of errors and informs the user of how many fields were
                    incorrectly entered*/
                if (count($errors) == 1) {
                    $message = "There was 1 error in the form.";
                } else {
                    $message = "There were " . count($errors) . " errors in the form.";
        } else { // Form has not been submitted.
            $org_name = "";
            $org_website = "";
            $org_contact = "";
            $org_conemail = "";
            $org_contel = "";
            $userid = "";
            $org_uploadcapt = "";
    //THE FOLLOWING CODE IS FOR THE UPLOADING OF IMAGES AND FILES
    // set the max upload size in bytes
    if (isset ($_POST ['submit']))
                //define the path to the upload folder
                // Use This On The Local Hosting Machine
                //$destination = 'C:/upload_test/';
                // Use This On The Live Server
                require_once('classes/Upload.php');
                try {
                    $upload = new Gp1_Upload($destination);
                    $upload->setMaxSize($max);
                    $upload->move();
                    $result = $upload->getMessages();
                } catch (Exception $e) {
                    echo $e->getMessage();
    // END OF UPLOADING OF IMAGES AND FILES
    ?>
    <title>Horse Events</title>
    <?php include_once("includes/meta.inc.php");?>
    <?php include_once("includes/cssfavgoogle.inc.php");?>
    <link href="css/adminpanel.css" rel="stylesheet" type="text/css" />
    <style>
    input[type="number"] {
        width:40px;
    </style>
    </head>
    <body>
    <div id="wrapper">
        <div id="admincontent">
    <form id="newvenue" action="neworganiser.php" method="post" enctype="multipart/form-data" >
          <?php if (!empty ($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
          <?php if (!empty ($errors)) {display_errors($errors); } ?>
          <?php
              // THIS CODE DISPLAYS ERROR MESSAGES FOR THE FILE UPLOADS
              if (isset($result)){
              echo '<ul>';
              foreach ($result as $message){
                  echo "<li>$message</li>";
              echo '</ul>';
           ?>
    <br />
          <table id="neweventdisplay" cellpadding="5"  border="0">
        <tr>
      <td></td>
      <td><input type="hidden" name="user_id"  value="<?php echo $url_userid ['user_id']; ?>" /></td>
      </tr>
      <tr>
      <td> <span class="compuls">*</span></td>
        <td>Organisers Name</td>
        <td><input class="input80px" id="org_name" name="org_name" type="text" />
         </td>
      </tr>
          <tr>
          <td><span class="compuls">*</span></td>
        <td>Their Website</td>
        <td><input class="input80px" id="org_website" name="org_website" type="text" /></td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
        <td>Organisers Contact</td>
        <td><input id="org_contact" name="org_contact" type="text" />eg: Mrs Jean Kelly</td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
        <td>Contact Email</td>
        <td><input class="input80px" id="org_conemail" name="org_conemail" type="text" />
          </td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
      <td>Contact Tel No.</td>
      <td><input id="org_contel" name="org_contel" type="text" /></td>
      </tr>
      <tr>
      <td></td>
      <td><label for="image">Upload image:</label></td>
      <td><p>
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>" />
    <input type="file" name="image" id="image" />
    </p></td>
    </tr>
      <tr>
      <td></td>
      <td>Details about your upload</td>
      <td><input class="input80px" id="org_uploadcapt" name="org_uploadcapt" type="text"  /></td>
    </tr>
      <tr>
      <td></td>
      <td><input type="submit" name="submit" id="submit" value="Add Your Organiser"></td>
      </tr>
      <tr>
      <td class="heading"> </td>
      <td></td>
      </tr>
    </table>
    <a  class="delete" href="controlpanel.php">Cancel</a>
    </form>
        </div>
    I have added the code you kindly forwarded but am getting an error,  I am still trying to learn the basics of php and am unsure of what to do next, my php Upload.php now looks like
    <?php
    class Gp1_Upload{
      protected $_uploaded = array();
      protected $_destination;
      protected $_max = 100000;
      protected $_messages = array();
      protected $_permitted = array('image/gif',
                                    'image/jpeg',
                                    'image/pjpeg',
                                    'image/png');
      protected $_renamed = false;
      protected $_filenames = array();
      public function __construct($path) {
        if (!is_dir($path) || !is_writable($path)) {
          throw new Exception("$path must be a valid, writable directory.");
        $this->_destination = $path;
        $this->_uploaded = $_FILES;
      public function getMaxSize() {
        return number_format($this->_max/100000, 1) . 'kB';
      public function setMaxSize($num) {
        if (!is_numeric($num)) {
          throw new Exception("Maximum size must be a number.");
        $this->_max = (int) $num;
      public function move($overwrite = false) {
        $field = current($this->_uploaded);
        if (is_array($field['name'])) {
          foreach ($field['name'] as $number => $filename) {
            // process multiple upload
            $this->_renamed = false;
            $this->processFile($filename, $field['error'][$number], $field['size'][$number], $field['type'][$number], $field['tmp_name'][$number], $overwrite);   
        } else {
          $this->processFile($field['name'], $field['error'], $field['size'], $field['type'], $field['tmp_name'], $overwrite);
      public function getMessages() {
        return $this->_messages;
      protected function checkError($filename, $error) {
        switch ($error) {
          case 0:
            return true;
          case 1:
          case 2:
            $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
            return true;
          case 3:
            $this->_messages[] = "Error uploading $filename. Please try again.";
            return false;
          case 4:
            $this->_messages[] = 'No file selected.';
            return false;
          default:
            $this->_messages[] = "System error uploading $filename. Contact webmaster.";
            return false;
      protected function checkSize($filename, $size) {
        if ($size == 0) {
          return false;
        } elseif ($size > $this->_max) {
          $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
          return false;
        } else {
          return true;
      protected function checkType($filename, $type) {
        if (empty($type)) {
          return false;
        } elseif (!in_array($type, $this->_permitted)) {
          $this->_messages[] = "$filename is not a permitted type of file.";
          return false;
        } else {
          return true;
      public function addPermittedTypes($types) {
        $types = (array) $types;
        $this->isValidMime($types);
        $this->_permitted = array_merge($this->_permitted, $types);
      protected function isValidMime($types) {
        $alsoValid = array('image/tiff',
                           'application/pdf',
                           'text/plain',
                           'text/rtf');
          $valid = array_merge($this->_permitted, $alsoValid);
        foreach ($types as $type) {
          if (!in_array($type, $valid)) {
            throw new Exception("$type is not a permitted MIME type");
      protected function checkName($name, $overwrite) {
        $nospaces = str_replace(' ', '_', $name);
        if ($nospaces != $name) {
          $this->_renamed = true;
        if (!$overwrite) {
          $existing = scandir($this->_destination);
          if (in_array($nospaces, $existing)) {
            $dot = strrpos($nospaces, '.');
            if ($dot) {
              $base = substr($nospaces, 0, $dot);
              $extension = substr($nospaces, $dot);
            } else {
              $base = $nospaces;
              $extension = '';
            $i = 1;
            do {
              $nospaces = $base . '_' . $i++ . $extension;
            } while (in_array($nospaces, $existing));
            $this->_renamed = true;
        return $nospaces;
      protected function processFile($filename, $error, $size, $type, $tmp_name, $overwrite) {
        $OK = $this->checkError($filename, $error);
        if ($OK) {
          $sizeOK = $this->checkSize($filename, $size);
          $typeOK = $this->checkType($filename, $type);
          if ($sizeOK && $typeOK) {
            $name = $this->checkName($filename, $overwrite);
            $success = move_uploaded_file($tmp_name, $this->_destination . $name);
            if ($success) {
                $message = "$filename uploaded successfully";
                if ($this->_renamed) {
                  $message .= " and renamed $name";
                $this->_messages[] = $message;
            } else {
              $this->_messages[] = "Could not upload $filename";
      public getFilenames() {
        return $this->_filenames;
    ?>
    The error is Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE.   
    I have not worked with oop before and have only very briefly looked at the principle was on my foundation degree.

  • Upload image in an html form to be emailed

    Hi everyone. Here is another one of my last minute, hurry up and wait requests.
    I have to create a form that will enable the viewer to upload an image and send the
    form on its way to a predetermined email address. This is for a contest starting tomorrow.
    The form has been made and works. The only thing I haven't worked out yet is the "upload image"
    feature. This is absolutely necessary and must be included. I have tested this several times and all the data
    comes thru. What I need is for an image to go along with the form fields and appear when the email is opened.
    With all due respect I do not have a very long learning curve here so if anyone can just provide
    me with the code, both html and php, instruct me exactly where to place it I would be
    extremely appreciative.
    here is the temporary link:
    Sirui/Argraph Wildlife-Landscape Photo Contest
    The image upload button will be in between the two horizontal rules towards the bottom of the form;
    above the submit/reset buttons.
    Thanks in advance as always.
    -Cliff-

    Below is the code and php for your complete form together with the file upload field and code. How you style the form and validate the form fields (if your going to) is down to you. Change the email address marked in red to that of the recipient you want the information to go to.
    You need to copy all the code and save it with a php extension so instead of:
    SiruiWildlifePhotoContestEntryForm.html
    This:
    SiruiWildlifePhotoContestEntryForm.php
    Obvioulsy being php it only works if the file is on a php enabled server so if you dont have a local testing server you need to upload it to your remote server before it will work.
    <?php
    if(isset($_POST['Submit']))
    //The form has been submitted, prep a nice thank you message
    $output = '<h1>Thanks for your file and message!</h1>';
    //Set the form flag to no display (cheap way!)
    $flags = 'style="display:none;"';
    //Deal with the email
    $to = 'yourEmailAddress.com';
    $subject = 'Competition Entry';
    $LastName = ($_POST['LastName']);
    $FirstName = ($_POST['FirstName']);
    $Email = ($_POST['Email']);
    $Phone = ($_POST['Phone']);
    $Address1 = ($_POST['Address1']);
    $Address2 = ($_POST['Address2']);
    $City = ($_POST['City']);
    $State = ($_POST['State']);
    $Zip = ($_POST['Zip']);
    $Dealer = ($_POST['Dealer']);
    $TripodMonopodHead = ($_POST['TripodMonopodHead']);
    $CameraLens = ($_POST['CameraLens']);
    $ImageEntry = ($_POST['ImageEntry']);
    $DepositWhere = ($_POST['DepositWhere']);
    $YouTubePage = ($_POST['YouTubePage']);
    $attachment = chunk_split(base64_encode(file_get_contents($_FILES['file']['tmp_name'])));
    $filename = $_FILES['file']['name'];
    $boundary =md5(date('r', time()));
    $headers = "From: [email protected]\r\nReply-To: [email protected]";
    $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
    $message = "Last Name: $LastName\n\n";
    $message .= "First Name: $FirstName\n\n";
    $message .= "Email: $Email\n\n";
    $message .= "Phone: $Phone\n\n";
    $message .= "Address1: $Address1\n\n";
    $message .= "Address2: $Address2\n\n";
    $message .= "City: $City\n\n";
    $message .= "State: $State\n\n";
    $message .= "Zip: $Zip\n\n";
    $message .= "Dealer: $Dealer\n\n";
    $message .= "Tripod Monopod Head: $TripodMonopodHead\n\n";
    $message .= "Camera Lens: $CameraLens\n\n";
    $message .= "Deposit Where: $DepositWhere\n\n";
    $message .= "You Tube Page: $YouTubePage\n\n";
    $message.="This is a multi-part message in MIME format.
    --_1_$boundary
    Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
    --_2_$boundary
    Content-Type: text/plain; charset=\"iso-8859-1\"
    Content-Transfer-Encoding: 7bit
    $message
    --_2_$boundary--
    --_1_$boundary
    Content-Type: application/octet-stream; name=\"$filename\"
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment
    $attachment
    --_1_$boundary--";
    mail($to, $subject, $message, $headers);
    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>MailFile</title>
    </head>
    <body>
    <?php echo $output; ?>
    <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" <?php echo $flags;?>>
    <p><label for="LastName" class="barheader">Last Name:</label>
    <input name="LastName" type="text" id="LastName" size="28" maxlength="50" />
    </p>
    <p><label for="FirstName" class="barheader">First Name:</label>
    <input name="FirstName" type="text" id="FirstName" size="28" maxlength="50" />
    </p>
    <p><label for="Email" class="barheader">Email:</label>
    <input name="Email" type="text" id="Email" size="50" maxlength="75" />
    </p>
    <p><label for="Phone" class="barheader">Phone:</label>
    <input name="Phone" type="text" id="Phone" size="12" maxlength="15" />
    </p>
    <p><label for="Address1" class="barheader">Address 1:</label>
    <input name="Address1" type="text" id="Address1" size="75" maxlength="100" />
    </p>
    <p><label for="Address2" class="barheader">Address 2:</label>
    <input name="Address2" type="text" id="Address2" size="75" maxlength="100" />
    </p>
    <p><label for="City" class="barheader">City:</label>
    <input name="City" type="text" id="City" size="33" />
    </p>
    <p><label for="State"><span class="barheader">State:</span></label>
    <input name="State" type="text" id="State" size="2" maxlength="2" />
    </p>
    <p><label for="Zip" class="barheader">Zip:</label>
    <input name="Zip" type="text" id="Zip" size="10" maxlength="10" />
    </p><label for="Dealer" class="barheader">Dealer:</label>
    <input name="Dealer" type="text" id="Dealer" size="100" maxlength="150" />
    </p>
    <p><label for="Tripod/Monopod/Head Used:" class="barheader">Tripod/Monopod/Head Used:</label>
    <input name="TripodMonopodHead" type="text" id="Tripod/Monopod/Head Used:" size="75" maxlength="100" />
    </p>
    <p><label for="YouTubePage" class="barheader">Camera/Lens Used:</label>
    <input name="CameraLens" type="text" id="Camera/Lens Used:" size="75" maxlength="100" />
    </p>
    <p><label for="Image/Entry:" class="barheader">Image/Entry #:</label>
    <input name="ImageEntry" type="text" id="Image/Entry:" size="25" maxlength="25" />
    </p>
    <p></p>Where will you deposit your entry?:</p>
    <p><label for="DepositWhere"></label>
    <input name="DepositWhere" type="text" id="DepositWhere:" size="20" maxlength="50" />
    </p>
    <p><label for="YouTubePage" class="barheader">For YouTube Videos: URL to your YouTube page:</label>
    <input name="YouTubePage" type="text" id="YouTubePage" size="50" maxlength="100" />
    </p>
    <p>
    <label for="file">Attach File</label> <input type="file" name="file" id="file"></p>
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    <input type="reset" name="Reset" id="Reset" value="Reset" />
    </form>
    </body>
    </html>

  • Upload image into mysql database residing on  remote server is not working?

    hello to all,
    i need ur help,we hav online site .
    i have to upload image(which can b from any pc) into mysql database residing on remote server of which we (don't hav actual path of that server).
    the solution i'm using is working correctly on local bt when transfer it to server it shows
    java.io.FileNotFoundException: (No such file or directory)
    i have used multipartRequest to access parameter of file type input.
    all variables and related packages r imported properly.no prblm in that.
    code is here....................................
    try {
    MultipartRequest multi = new MultipartRequest(request, ".", 500000 * 1024);
    File f = multi.getFile("uploadfile");
    out.println(f.getName());
    filename = f.getName();
    String type = multi.getContentType(f.getName());
    fis=new FileInputStream(filename);
    byte b[]=new byte[fis.available()];
    fis.read(b);
    fis.close();
    Blob blob=new SerialBlob(b);
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://10.1.52.206:3306/test?user=root&password=delhi");
    String query="insert into uploads (FILENAME,BINARYFILE,) values (?,?)";
    pstmt=con.prepareStatement(query);
    pstmt.setString(1,filename);
    pstmt.setBlob(2,blob);
    int i=pstmt.executeUpdate();
    if(i>0)
    out.println("Image Stored in the Database");
    else
    out.println("Failed");
    } catch (Exception ex) {
    out.print("*******************"+ex);
    ex.printStackTrace();
    please suggest me the way to upload image to remote server** not on local server.
    its urgent.
    Edited by: JavaDevS on Jul 28, 2008 11:41 AM

    i need ur help,we hav online site .Please don't use these juvenile abbreviations. It's impolite when you're asking for assistance not to make the effort to spell out all of the words. Moreover in a forum with an international readership the use of standard English will reduce the possibility of confusion.
    I presume that your file upload is being placed in a different directory from that which you were expecting. I would suggest logging all paths (specifically filename) to see if this is an unexpected value.
    Please explain further what you mean by "local" - is this a stand-alone application, or merely running a copy of the server on your local machine and doing the transfer (via the browser) to that? Are there any other differences such as the browser used?

  • How do I get the Filename after uploading

    Howdy friends, here's the problem:
    I allow users to upload images on a previous page using
    CFFile. On the following action page, I want to be able to send an
    email telling the site owner about the new file uploads.
    The problem is that what I get instead of the filename is:
    D:\TEMP\wwwroot-tmp\neotmp43652.tmp
    However, the correct File appears to be uploaded.
    So what do I do to obtain the correct filename?
    And here's the code:
    <cfmail to="[email protected]"
    from="#FORM.Address#"
    subject="Add my photos please">
    Attention:
    I have uploaded the following pictures:
    <cfif #FORM.FileName1# GT ''>
    #FORM.FileName1#
    #Form.Description1#
    </cfif>
    Thank you,
    #FORM.Name#
    </cfmail>
    <cfif #FORM.FileName1# NEQ ''>
    <cffile action="upload" filefield="form.filename1"
    destination="D:\Hosting\mysite\NewGallery\"
    nameconflict="overwrite">
    </cfif>

    Its in cffile.clientFile. Check out
    http://livedocs.macromedia.com/coldfusion/5.0/CFML_Reference/Tags20.htm#1098492
    for all the cffile variables available after an upload.
    After your cffile, do a <CFDUMP VAR=#cffile#> to see
    all the goodies.

  • Delete an uploaded image

    Hi
    Can anyone give me instructions for deleting an uploaded image without deleting the whole record? For example, I have a record with an uploaded image, the image name stored in the table and the image in a directory. I change my mind and want no image associated with the record. How do I delete the image associated with the record and make that image name field null?
    Thanks

    OK, I have it working in a round about way. I'm sure with Gunters help I could get it going the 'proper way" but for now this solution seems to be working.
    on my detail list I added a link "remove current file" which only shows on the conditional region "show if file exists" so if there is no file this link will not show.. so far so good.
    I think pass the URL parameter to a page which I'm filter by URL ID parameted called "deletefile.php"
    I then added an update record form and only included the field that is storing the filename. In the wizard I inserted the field as a hidden field. I added a second hidden field and called it "null" and left the value for it blank.
    In the update record behaviour you can choose to get the values from any form element in the form area. So I chose to get the values from the hiidden object "null".
    when you submit form it will then put the field for the file back to "null'
    I'm sure i can get the form to delete the file as well. I'll work on that next.
    This does seem a little dirty but seems to be working perfectly fine.
    Hope this helps anyone.

  • Upload image with Zprogram instead se78

    Dear Gurus ,
    I founf in sdn a useful program that upload images instead se78.
    It works fine but i cant find how to pass the Description of the image....
    Can you give me a hint ?
    Look the code ....
    REPORT  ZTEST2.
    TYPE-POOLS: SBDST.
    TABLES: STXBITMAPS.
    CONSTANTS:
      C_BDS_CLASSNAME TYPE SBDST_CLASSNAME VALUE 'DEVC_STXD_BITMAP',
      C_BDS_CLASSTYPE TYPE SBDST_CLASSTYPE VALUE 'OT',          " others
      C_BDS_MIMETYPE  TYPE BDS_MIMETP      VALUE 'application/octet-stream',
      C_BDS_ORIGINAL  TYPE SBDST_DOC_VAR_TG VALUE 'OR'.
    * Globals and globals for dynpro fields
    DATA: G_OBJECTTYPE(20)   TYPE C,
          G_NEW_RESOLUTION   LIKE STXBITMAPS-RESOLUTION,
          G_STXBITMAPS       TYPE STXBITMAPS,
          G_STXH             TYPE STXH,
          G_TECHINFO         TYPE RSSCG,
          T_SIZE(40),
          BDS_DESCRIPTION  LIKE BAPISIGNAT-PROP_VALUE VALUE 'LALALA'.
    CONSTANTS:
          C_OBJECTTYPE_BDS      LIKE G_OBJECTTYPE VALUE 'BDS',
          C_OBJECTTYPE_STDTEXT  LIKE G_OBJECTTYPE VALUE 'OBTEXT',
          C_OBJECTTYPE_GRTEXT   LIKE G_OBJECTTYPE VALUE 'OBGRAPHICS'.
    DATA: P_FILENAME       TYPE RLGRAP-FILENAME,
                   P_OBJECT         TYPE STXBITMAPS-TDOBJECT,
                   P_ID             TYPE STXBITMAPS-TDID,
                   P_BTYPE          TYPE STXBITMAPS-TDBTYPE,
                   P_FORMAT         TYPE C,
                   P_TITLE          LIKE BDS_DESCRIPTION,
                   P_RESIDENT       TYPE STXBITMAPS-RESIDENT,
                   P_AUTOHEIGHT     TYPE STXBITMAPS-AUTOHEIGHT,
                   P_BMCOMP         TYPE STXBITMAPS-BMCOMP.
    DATA  L_FILE TYPE STRING..
    DATA: L_FILENAME        TYPE STRING,
          L_BYTECOUNT       TYPE I,
          L_BDS_BYTECOUNT   TYPE I.
    DATA: L_COLOR(1)        TYPE C,
          L_WIDTH_TW        TYPE STXBITMAPS-WIDTHTW,
          L_HEIGHT_TW       TYPE STXBITMAPS-HEIGHTTW,
          L_WIDTH_PIX       TYPE STXBITMAPS-WIDTHPIX,
          L_HEIGHT_PIX      TYPE STXBITMAPS-HEIGHTPIX.
    DATA: L_BDS_OBJECT      TYPE REF TO CL_BDS_DOCUMENT_SET,
          L_BDS_CONTENT     TYPE SBDST_CONTENT,
          L_BDS_COMPONENTS  TYPE SBDST_COMPONENTS,
          WA_BDS_COMPONENTS TYPE LINE OF SBDST_COMPONENTS,
          L_BDS_SIGNATURE   TYPE SBDST_SIGNATURE,
          WA_BDS_SIGNATURE  TYPE LINE OF SBDST_SIGNATURE,
          L_BDS_PROPERTIES  TYPE SBDST_PROPERTIES,
          WA_BDS_PROPERTIES TYPE LINE OF SBDST_PROPERTIES.
    DATA  WA_STXBITMAPS TYPE STXBITMAPS.
    PARAMETERS: P_FILE TYPE  RLGRAP-FILENAME OBLIGATORY.
    PARAMETERS: P_MATNR LIKE MARA-MATNR OBLIGATORY.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          FIELD_NAME = 'P_FILE'
        IMPORTING
          FILE_NAME  = P_FILE.
    START-OF-SELECTION.
      DATA: P_NAMEX    TYPE STXBITMAPS-TDNAME.
      MOVE P_MATNR TO P_NAMEX.
      DATA: FILELENGTH  TYPE  I.
      DATA: BEGIN OF L_BITMAP OCCURS 0,
              L(64) TYPE X,
            END OF L_BITMAP.
      L_FILE = P_FILE.
    *SELECT SINGLE * FROM STXBITMAPS WHERE TDNAME = P_NAMEX.
    *  IF SY-SUBRC NE 0.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME                = L_FILE
          FILETYPE                = 'BIN'
        IMPORTING
          FILELENGTH              = L_BYTECOUNT
        TABLES
          DATA_TAB                = L_BITMAP
        EXCEPTIONS
          FILE_OPEN_ERROR         = 2
          FILE_READ_ERROR         = 3
          NO_BATCH                = 1
          GUI_REFUSE_FILETRANSFER = 4
          INVALID_TYPE            = 5
          NO_AUTHORITY            = 6
          UNKNOWN_ERROR           = 7
          BAD_DATA_FORMAT         = 8
          HEADER_NOT_ALLOWED      = 9
          SEPARATOR_NOT_ALLOWED   = 10
          HEADER_TOO_LONG         = 11
          UNKNOWN_DP_ERROR        = 12
          ACCESS_DENIED           = 13
          DP_OUT_OF_MEMORY        = 14
          DISK_FULL               = 15
          DP_TIMEOUT              = 16
          OTHERS                  = 17.
    *    call method l_bds_object->get_info
    *         exporting
    *              classname  = c_bds_classname
    *              classtype  = c_bds_classtype
    *              object_key = l_object_key
    *         changing
    *              signature  = l_bds_signature
    *         exceptions
    *              nothing_found  = 1
    *              others         = 2.
      DATA: P_DOCID          TYPE STXBITMAPS-DOCID.
      DATA: P_RESOLUTION  LIKE  STXBITMAPS-RESOLUTION.
      DATA: L_OBJECT_KEY TYPE SBDST_OBJECT_KEY.
      CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP_BDS'
        EXPORTING
          COLOR                    = 'X'
          FORMAT                   = 'BMP'
          RESIDENT                 = P_RESIDENT
          BITMAP_BYTECOUNT         = L_BYTECOUNT
          COMPRESS_BITMAP          = 'X'
        IMPORTING
          WIDTH_TW                 = L_WIDTH_TW
          HEIGHT_TW                = L_HEIGHT_TW
          WIDTH_PIX                = L_WIDTH_PIX
          HEIGHT_PIX               = L_HEIGHT_PIX
          DPI                      = P_RESOLUTION
          BDS_BYTECOUNT            = L_BDS_BYTECOUNT
        TABLES
          BITMAP_FILE              = L_BITMAP
          BITMAP_FILE_BDS          = L_BDS_CONTENT
        EXCEPTIONS
          FORMAT_NOT_SUPPORTED     = 1
          NO_BMP_FILE              = 2
          BMPERR_INVALID_FORMAT    = 3
          BMPERR_NO_COLORTABLE     = 4
          BMPERR_UNSUP_COMPRESSION = 5
          BMPERR_CORRUPT_RLE_DATA  = 6
          OTHERS                   = 7.
      IF SY-SUBRC <> 0.
      ENDIF.
      CREATE OBJECT L_BDS_OBJECT.
      WA_BDS_COMPONENTS-DOC_COUNT  = '1'.
      WA_BDS_COMPONENTS-COMP_COUNT = '1'.
    WA_BDS_COMPONENTS-MIMETYPE   = C_BDS_MIMETYPE."application/octet-stream
      WA_BDS_COMPONENTS-COMP_SIZE  = L_BDS_BYTECOUNT.
      APPEND WA_BDS_COMPONENTS TO L_BDS_COMPONENTS.
      WA_BDS_SIGNATURE-DOC_COUNT = '1'.
      APPEND WA_BDS_SIGNATURE TO L_BDS_SIGNATURE.
      L_OBJECT_KEY = P_NAMEX.
      CALL METHOD L_BDS_OBJECT->CREATE_WITH_TABLE
        EXPORTING
          CLASSNAME  = C_BDS_CLASSNAME "DEVC_STXD_BITMAP
          CLASSTYPE  = C_BDS_CLASSTYPE "OT
          COMPONENTS = L_BDS_COMPONENTS
          CONTENT    = L_BDS_CONTENT
        CHANGING
          SIGNATURE  = L_BDS_SIGNATURE
          OBJECT_KEY = L_OBJECT_KEY
        EXCEPTIONS
          OTHERS     = 1.
      IF SY-SUBRC = 0.
        READ TABLE L_BDS_SIGNATURE INDEX 1 INTO WA_BDS_SIGNATURE
        TRANSPORTING DOC_ID.
        IF SY-SUBRC = 0.
          P_DOCID = WA_BDS_SIGNATURE-DOC_ID.
          WA_STXBITMAPS-TDNAME     = P_NAMEX.
          WA_STXBITMAPS-TDOBJECT   = 'GRAPHICS'.
          WA_STXBITMAPS-TDID       = 'BMAP'.
          WA_STXBITMAPS-TDBTYPE    = 'BCOL'.
          WA_STXBITMAPS-DOCID      = P_DOCID.
          WA_STXBITMAPS-WIDTHPIX   = L_WIDTH_PIX.
          WA_STXBITMAPS-HEIGHTPIX  = L_HEIGHT_PIX.
          WA_STXBITMAPS-WIDTHTW    = L_WIDTH_TW.
          WA_STXBITMAPS-HEIGHTTW   = L_HEIGHT_TW.
          WA_STXBITMAPS-RESOLUTION = P_RESOLUTION.
          WA_STXBITMAPS-RESIDENT   = P_RESIDENT.
          WA_STXBITMAPS-AUTOHEIGHT = P_AUTOHEIGHT.
          WA_STXBITMAPS-BMCOMP     = P_BMCOMP.
          INSERT INTO STXBITMAPS VALUES WA_STXBITMAPS.
        ENDIF.
      ENDIF.
    *--OAER
      DATA: SIGN    TYPE TABLE OF BAPISIGNAT WITH HEADER LINE,
          COMP    TYPE TABLE OF BAPICOMPON WITH HEADER LINE,
          CONTENT TYPE TABLE OF BAPICONTEN WITH HEADER LINE,
          CONTHEX TYPE TABLE OF SOLIX WITH HEADER LINE,
          DOCID TYPE SOFOLENTI1-DOC_ID,
          OBJKEY TYPE BAPIBDS01-OBJKEY,
          DOC_DATA TYPE  SOFOLENTI1.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          FILENAME = L_FILE
          FILETYPE = 'BIN'
        TABLES
          DATA_TAB = CONTENT.
      BREAK FTELLI.
      OBJKEY = P_NAMEX.
      SIGN-DOC_COUNT = '00000001'.
      SIGN-PROP_NAME = 'BDS_DOCUMENTCLASS'.
      SIGN-PROP_VALUE = DOC_DATA-OBJ_TYPE.
      APPEND SIGN.
      SIGN-DOC_COUNT = '00000001'.
      SIGN-PROP_NAME = 'BDS_CONTREP'.
      SIGN-PROP_VALUE = ''.
      APPEND SIGN.
      SIGN-DOC_COUNT = '00000001'.
      SIGN-PROP_NAME = 'BDS_DOCUMENTTYPE'.
      SIGN-PROP_VALUE = 'BDS_IMAGE'.
      APPEND SIGN.
      SIGN-DOC_COUNT = '00000001'.
      SIGN-PROP_NAME = 'BDS_TITLE'.
      SIGN-PROP_VALUE = 'DIMITRIS'.
      APPEND SIGN.
      SIGN-DOC_COUNT = '00000001'.
      SIGN-PROP_NAME = 'DESCRIPTION'.
      SIGN-PROP_VALUE = DOC_DATA-OBJ_DESCR.
      APPEND SIGN.
      SIGN-DOC_COUNT = '00000001'.
      SIGN-PROP_NAME = 'LANGUAGE'.
      SIGN-PROP_VALUE = SYST-LANGU.
      APPEND SIGN.
      COMP-DOC_COUNT = 1.
      COMP-COMP_COUNT = 1.
    *    comp-comp_id = doc_data-obj_descr.
      COMP-MIMETYPE = 'image/jpeg'.
      COMP-COMP_SIZE = DOC_DATA-DOC_SIZE.
      APPEND COMP.
      CALL FUNCTION 'BDS_BUSINESSDOCUMENT_CREA_TAB'
        EXPORTING
          CLASSNAME       = 'PICTURES'
          CLASSTYPE       = 'OT'
          OBJECT_KEY      = OBJKEY "p_matnr
        TABLES
          SIGNATURE       = SIGN
          COMPONENTS      = COMP
          CONTENT         = CONTENT
        EXCEPTIONS
          NOTHING_FOUND   = 1
          PARAMETER_ERROR = 2
          NOT_ALLOWED     = 3
          ERROR_KPRO      = 4
          INTERNAL_ERROR  = 5
          NOT_AUTHORIZED  = 6
          OTHERS          = 7.
      COMMIT WORK AND WAIT.
      REFRESH: CONTENT, CONTHEX, SIGN, COMP.
    Thanks a lot ....

    Hi,
    You should be changing the URL passed to the URLRequest to
    point to your server. Please check the URL from the HTML page
    generated by your JSP and set the URLRequest URL accordingly.
    Hope this helps.

  • How to upload images to a DB and then view them in the site?

    Hi
    I have a form, and i want it to insert some data on a DB, so
    that the site can display that information. But i'm not able to
    upload images or files, because dreamweaver does not have a file
    upload option.
    I'm using PHP, can anyone help me on how to upload a image
    and display it on the web site?

    > I don't think its possible to store files in a
    > database.
    It is. But it's not a great way to do things.
    > store it's path in the DB
    Actually, what you want to store in the DB is the filename
    only. Put the
    path into the HTML. That way you don't have to change every
    record when you
    rename a folder.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "IndioDoido" <[email protected]> wrote in
    message
    news:e1rdmu$819$[email protected]..
    > Hi there!
    >
    > I don't want to upload a image to a DB...i want to
    upload it to a folder
    > but
    > store it's path in the DB. I don't think its possible to
    store files in a
    > database.
    > After the upload i want to display the image on the
    page, with its name
    > and
    > discription, in other words, with the information
    uploaded from the web
    > form
    > created with dreamweaver record insertion form.
    >

  • Uploaded  image not shown

    hello experts,
    I have been done a web java application in struts. Its working fine in my pc, where i have netbeans 6.0 IDE. But when i deployed the war file at client pc, where jdk1.5 and tomcat 5.5.9 are installed, its not showing newly uploaded image but it shows all the images which were present while creating war file from my pc. But the image is uploaded. I upload the images into c:\rh\web\photo and c:\rh\build\web\photo ( unless i place here, i can't able see the newly uploaded image without stopping and running the application). I feel the only difference between client Pc and my Pc is, I run my application using netbeans whereas client pc doesn't have netbeans(rest all it has), through tomcat it runs there.
    Any help will be greatly appreciated.
    Thanks,
    SRI.

    You know that HTML runs at the client side?
    You know that file system paths are not the same as URL's?
    You know that file system paths points to the file system of the local machine?
    If you have for example a <img src="c:/foo/bar.gif" /> in your HTML, which is been sent from the server to the client side, the web browser will try to search for "c:/foo/bar.gif" in the local file system. This is obviously not going to work when the image is actually located at the server's file system.
    You need to replace file system paths by URL's, so that the client can retrieve the image from the server. When the image is not available in public domain, then create a servlet which accesses the server's file system and sends the desired image to the response. Finally let the URL of the image point to that servlet, along with some unique ID or filename. You may find this example useful: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • Showing the thumbnail view of the uploaded image

    Hello Experts,
    I am developing a website in jsp, where i have a module for patron uploading their photo into the server.
    After a lot of gooling and searches in this site, i found code to upload the image and it uploads perfectly into the specified folder at server also. But my need is showing the uploaded image at once, after the image is uploaded. i used
    <img src="images\<%=filepath%>"> and also
    <img src="ImageServlet\file=<%=filepath%>"> both are not working.
    any suggession will be greatly appreciated.
    Regards,
    Sri.

    Thanks for your suggessions, i have placed my code below, i think i am closing the file afrer writing.
    If anything is failed to close, please let me know.
                if (request.getParameter("upload") != null) {
                    String contentType = request.getContentType();
                    if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
                        DataInputStream in = new DataInputStream(request.getInputStream());
                        int formDataLength = request.getContentLength();
                        byte dataBytes[] = new byte[formDataLength];
                        int byteRead = 0;
                        int totalBytesRead = 0;
                        while (totalBytesRead < formDataLength) {
                            byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
                            totalBytesRead += byteRead;
                        String file = new String(dataBytes);
                        String saveFile = file.substring(file.indexOf("filename=\"") + 10);
                        saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
                        saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
                        String ext = "";
                        if (saveFile.indexOf(".") != -1) {
                            ext = saveFile.substring(saveFile.lastIndexOf("."));
                        int lastIndex = contentType.lastIndexOf("=");
                        String boundary = contentType.substring(lastIndex + 1, contentType.length());
                        int pos;
                        pos = file.indexOf("filename=\"");
                        pos = file.indexOf("\n", pos) + 1;
                        pos = file.indexOf("\n", pos) + 1;
                        pos = file.indexOf("\n", pos) + 1;
                        int boundaryLocation = file.indexOf(boundary, pos) - 4;
                        int startPos = ((file.substring(0, pos)).getBytes()).length;
                        int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
                        if (ext.equalsIgnoreCase(".jpeg") || ext.equalsIgnoreCase(".jpg") || ext.equalsIgnoreCase(".gif") || ext.equalsIgnoreCase(".png") || ext.equalsIgnoreCase(".tiff")) {
                            String strFilePath = "";
                            String strCopyPath = "";
                            Properties props = new Properties();
                            try {
                                File filDBConfig = new File(strFilePath);
                                FileInputStream fiStream = new FileInputStream("C:\\sansri\\config.properties");
                                props.load(fiStream);
                                strFilePath = props.getProperty("db.photopath");
                                strCopyPath = props.getProperty("db.copypath");
                                fiStream.close();
                                filDBConfig = null;
                            } catch (Exception e) {
                                e.printStackTrace();
                                Photo = "Invalid File";
                            System.out.println("strFilePath " + strFilePath);
                            File fff = new File(strFilePath);
                            if (fff.exists() == false) {
                                fff.mkdirs();
                            fff = new File(strCopyPath);
                            if (fff.exists() == false) {
                                fff.mkdirs();
                            //copying into build to show uploaded image at once
                            Photo = request.getParameter("upload").concat(ext);
                            FileOutputStream fileOut = new FileOutputStream(strFilePath + "\\" + Photo);
                            fileOut.write(dataBytes, startPos, (endPos - startPos));
                            fileOut.flush();
                            fileOut.close();
                            //copying into web also to avoid unavailability of image while rebuilding
                            fileOut = new FileOutputStream(strCopyPath + "\\" + Photo);
                            fileOut.write(dataBytes, startPos, (endPos - startPos));
                            fileOut.flush();
                            fileOut.close();
                        } else {
                            Photo = "Invalid File";
                }{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Uploaded Images

    Greetings,
    Sorry for the noobness, but when one wishes to use an image as an item in a region (contenttype->image), it says to either browse for it, or to enter it's internal filename. Is there a way of viewing these already uploaded images in some sort of graphical way to see what is already out there and possibly choose it.
    Any help or pointing in the right direction greatly appreciated.
    -- Cliff Moon
    -- UTPA Webmaster

    But it isn't doing that either. I have to get the "My Products" graphic from my Mac for each post I make.
    Ah, just discovered something. While I don't have any images in the second tab when doing a new post, if I go to Edit a post, the image is there so you can add it again.

  • Uploading images with jsp-PLEASE HELP

    Hi
    I would like to allow users to upload images(photos) from the website im doing.
    i was gonna use perl which seems quite easy. Since everything else i used was jsp i thought i might try to do uploader in jsp (though its seems more difficult)
    id like to limit :
    the maximum file size to be uploaded ,
    the maximum width/height of the image file
    the list of the acceptable mime-types (Content-Types) -jpg, gif
    Any suggestions how to go about it PLEASE- ie. what packages, classes do i need- mimeparser, BufferedImage, FileFilter? cos im bit lost which classes to use.
    THANKS LOTS
    sabcarina

    This is the jsp File which helps me to upload the file
    But for this Jakarta Commons fileupload is needed which is normally provided with Tomcat 5.5
    The code is
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
    <%@ page import="org.apache.commons.fileupload.FileItem"%>
    <%@ page import="java.util.List"%>
    <%@ page import="java.util.Iterator"%>
    <%@ page import="java.util.*"%>
    <%@ page import="java.io.File"%>
    <%@ page import="com.common.*"%>
    <!--<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Process File Upload</title>
    </head>-->
    <%
         DerivedLastNoEntity objLastNoEntity=new DerivedLastNoEntity();
         DerivedLastNoObject objLastNo=(DerivedLastNoObject)objLastNoEntity.getData(new DerivedLastNoObject(10)).get(0);
         int lastNo=objLastNo.getLastNo();
         String forwardString=null;
         StringBuffer parameters=new StringBuffer();
            DiskFileUpload fu = new DiskFileUpload();
            // If file size exceeds, a FileUploadException will be thrown
            fu.setSizeMax(1000000);
            List fileItems = fu.parseRequest(request);
            Iterator itr = fileItems.iterator();
            while(itr.hasNext()) {
              FileItem fi = (FileItem)itr.next();
              //Check if not form field so as to only handle the file inputs
              //else condition handles the submit button input
              if(!fi.isFormField()) {
              String fileName=fi.getName();
              if(fileName.length()>0)
                   fileName=(++lastNo)+fileName.substring(fileName.lastIndexOf("."));
                   File fNew= new File(application.getRealPath("/"), fileName);
                   parameters.append("&fileName=/struts-blank/"+fileName);
                   fi.write(fNew);
         else
              if(fi.getFieldName().equals("forwardString"))
                   forwardString=fi.getString();
              else
                   parameters.append("&"+fi.getFieldName()+"="+fi.getString());
         objLastNo.setLastNo(lastNo);
         objLastNoEntity.edit(objLastNo);
         System.out.println("before "+forwardString);
         if(parameters.length()>0)
              if(forwardString.indexOf("?")<0)
                   forwardString=forwardString.concat(parameters.toString().replaceFirst("&","?"));
              else
                   forwardString=forwardString.concat(parameters.toString());
         System.out.println("after "+forwardString);
         response.sendRedirect(forwardString);
    %>
    <!--<body>
    Upload Successful!!
    </body>
    </html>-->Bye for now
    CSJakharia

  • Upload Images and giving an action to image

    Hi,
    I  want to upload images  and by clicking that image it must go to next view.
    Could you please suggest me some of the steps to upload image and to make an action on image.
    Regards,
    Anitha

    You can use FileUplod UI Element for uploading your photo.
    and to make image as action you can use LinkToAction UI Element and put the full image name(with file Ext) in ImageSource property of LinkToAction UI Element, after that create a action and put the required code for next level of prcessing
    use this running code for uploding you file
    String FileName = "temp;
           InputStream input = null;
           int i=0;
              FileIncreament();
              try {
                        String directory =".\\temp\\webdynpro\\web\\local\\yh1245_ftp"+
                        "\\Components\\com.yash.yh1245.Upload\\"+FileName+wdContext.currentContextElement().getCounter();
                             boolean sucsss = new File(directory).mkdir();
                             if(sucsss){
                                  wdComponentAPI.getMessageManager().reportSuccess("Directory Created ");
                                 File file = new File(directory+"\\"+wdContext.currentContextElement().getResourceURL().getResourceName().toString());
                                  FileOutputStream fos = new FileOutputStream(file);
                                  wdComponentAPI.getMessageManager().reportSuccess(file.getAbsolutePath());
                                  FilePath = file.getAbsolutePath();
                                  wdComponentAPI.getMessageManager().reportSuccess("AbsolutePath......."+file.getAbsolutePath());
                                  if(wdContext.currentContextElement().getResourceURL()!=null){
                                       input = wdContext.currentContextElement().getResourceURL().read(false);
                                       //wdComponentAPI.getMessageManager().reportSuccess("Resource is not null ");
                                       while((i = input.read())!=-1){
                                            fos.write(i);
                                  fos.flush();
                                  fos.close();
                                  wdComponentAPI.getMessageManager().reportSuccess("File Uploaded on server directory ");

Maybe you are looking for

  • SAP R/3 on Oracle 9i : check online backup

    Hi there, I would like to integrate a check on the status of the online database backup (which runs on a daily basis) into a central monitoring system. On way to do it is to check on OS level for the latest backup log file and read the status at the

  • Macbook pro retina - replaced battery quality and age?

    This question is about a Retina MacBook Pro, 15-inch, Early 2013 (MacBookPro10,1). It was originally purchased in April 2013. I would like to find information about the manufacture dates of batteries, and Apple's policies for hardware repairs and ref

  • Can't create PDF, Acrobat not activated

    I recently needed to move my system over from XP to Vista since programs were unresponsive due to virus infection.  Re-installed CS3 Design Premium which comes with Acrobat 8 Professional. Had no problem previously creating PDFs, but now sometimes I

  • Spam filtering before frontline

    Here's a whacky question, I have implemented frontline spam defense, and it is working beautifully (Thanks again Alex!) The only strange thing (which I am sure has something to dowith another aspect of my config) is that if an email is identified as

  • [AS][CS5] Multiple action folder scripts only 1 Indesign app

    Hi, With this post, I would like to ask a question. If you use multiple action folder scripts that processes multiple files using only 1 Indesign application, can problems occure when multiple files are submitted at the same time? How does applescrip