File upload field

I have a profile update page, with a file field where the user can upload a photo.
But I have a major problem. I know that the fileupload form cannot contain a value from a database.
When I submit the form without the image, it resets the photo field to blank.
I would like to know:
How can I upload a photo with checking if the same name is already in the folder?
How can I leave the field intact so that the current image stays on blank field?
This is my code
SQL
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "update_business")) {
  $updateSQL = sprintf("UPDATE users SET company_name=%s, comp_add1=%s, comp_add2=%s, comp_add3=%s, comp_city=%s, comp_postcode=%s, comp_tel=%s, comp_fax=%s, comp_email=%s, comp_web=%s, comp_description=%s, honors_awards=%s, industry=%s, logo=%s, bul1=%s, bul2=%s, bul3=%s, bul4=%s, bul5=%s, bul6=%s WHERE user_id=%s",
                       GetSQLValueString($_POST['company_name'], "text"),
                       GetSQLValueString($_POST['comp_add1'], "text"),
                       GetSQLValueString($_POST['comp_add2'], "text"),
                       GetSQLValueString($_POST['comp_add3'], "text"),
                       GetSQLValueString($_POST['comp_city'], "text"),
                       GetSQLValueString($_POST['comp_postcode'], "text"),
                       GetSQLValueString($_POST['comp_tel'], "text"),
                       GetSQLValueString($_POST['comp_fax'], "text"),
                       GetSQLValueString($_POST['comp_email'], "text"),
                       GetSQLValueString($_POST['comp_web'], "text"),
                       GetSQLValueString($_POST['comp_description'], "text"),
                       GetSQLValueString($_POST['honors_awards'], "text"),
                       GetSQLValueString($_POST['industry'], "text"),
                       GetSQLValueString($_FILES['ufile']['name'], "text"),
                       GetSQLValueString($_POST['bul1'], "text"),
                       GetSQLValueString($_POST['bul2'], "text"),
                       GetSQLValueString($_POST['bul3'], "text"),
                       GetSQLValueString($_POST['bul4'], "text"),
                       GetSQLValueString($_POST['bul5'], "text"),
                       GetSQLValueString($_POST['bul6'], "text"),
                       GetSQLValueString($_POST['user'], "int"));
  mysql_select_db($database_db, $db);
  $Result1 = mysql_query($updateSQL, $db) or die(mysql_error());
  $updateGoTo = "home.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  header(sprintf("Location: %s", $updateGoTo));
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "update_business")) {
  $updateSQL = sprintf("UPDATE users SET photo=%s WHERE user_id=%s",
                       GetSQLValueString($_FILES['ufile']['name'], "text"),
                       GetSQLValueString($_POST['user'], "int"));
  mysql_select_db($database_db, $db);
  $Result1 = mysql_query($updateSQL, $db) or die(mysql_error());
//define a maxim size for the uploaded images in Kb
define ("MAX_SIZE","50000");
//This function reads the extension of the file. It is used to determine if the file  is an image by checking the extension.
function getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
//This variable is used as a flag. The value is initialized with 0 (meaning no error  found) 
//and it will be changed to 1 if an errro occures. 
//If the error occures the file will not be uploaded.
$errors=0;
//checks if the form has been submitted
if(isset($_POST['Submit']))
     //reads the name of the file the user submitted for uploading
     $image=$_FILES['ufile']['name'];
     //if it is not empty
     if ($image)
     //get the original name of the file from the clients machine
         $filename = stripslashes($_FILES['ufile']['name']);
     //get the extension of the file in a lower case format
          $extension = getExtension($filename);
         $extension = strtolower($extension);
     //if it is not a known extension, we will suppose it is an error and will not  upload the file, 
    //otherwise we will do more tests
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
        //print error message
             echo '<h1>Unknown extension!</h1>';
             $errors=1;
         else
//get the size of the image in bytes
//$_FILES['image']['tmp_name'] is the temporary filename of the file
//in which the uploaded file was stored on the server
$size=filesize($_FILES['ufile']['tmp_name']);
//compare the size with the maxim size we defined and print error if bigger
if ($size > MAX_SIZE*1024)
    echo '<h1>You have exceeded the size limit!</h1>';
    $errors=1;
//we will give an unique name, for example the time in unix time format
//$image_name=time().'.'.$extension;
//the new name will be containing the full path where will be stored (images folder)
$newname="company_pics/".$image;
//we verify if the image has been uploaded, and print error instead
$copied = copy($_FILES['ufile']['tmp_name'], $newname);
if (!$copied)
    echo '<h1>Copy unsuccessfull!</h1>';
    $errors=1;
//If no errors registred, print the success message
if(isset($_POST['Submit']) && !$errors)
     echo "<h1>File Uploaded Successfully!</h1>";
<label>Upload Photo</label><br />
<input name="ufile" type="file" id="ufile" size="50" />
<br /><br />

Well I'm a newbie at OAS Portal so I used the Form based on a table and there in the FILE_ field I changed it from textbox to File Upload(binary), and then I ran the form and I filled all the textbox and then chose the file I wanted to upload I clicked on insert, then the row was inserted and then I tried to open the file but nothing happened!
=(
so probably is that the form is trying to save the file directly in the database right... so I must change the field type... right??

Similar Messages

  • How to 'clear' file upload field in forms

    In a form I am designing I need a 'clear' or 'reset' button that clears the entire form. This is easy to do, of course, but alas my form has a file upload field, and in Safari I just can't get that field to go back to it's default empty state.
    is there a secret way to force file upload fields in safari to reset, or is it just impossible?

    I've just done a quick search on bugzilla and came up with this http://bugzilla.opendarwin.org/show_bug.cgi?id=8248.

  • Problem in dynamically generating the file upload field

    Hello all
    I am using netbeans 5.5 and visualwebpack for my jsf project.
    i have a problem in dynamically generating the file upload field and using it.
    I have a panel say "panelA" which holds file upload fields.
    Depending upon the count value i generate the file upload field using following code snippet:
    Upload upload1 = new Upload();
    upload1.setId("upload1");
    getPanelA.getChildren().add(upload1);
    The page successfully shows up the file upload fields. While the user clicks the submit button, i have used following logic to perform upload:
    List components = getPanelA().getChildren();
    for(int i = 0; i<components.size(); i++){
    if(components.get(i) instanceof Upload){
    UploadedFile uploadedFile = ((Upload)components.get(i)).getUploadedFile();
    I am getting this UploadedFile object null.
    How can i solve this problem.

    Anyway,
    I solved the problem.
    Actually i was using label property of the upload field due to which i got null pointer exception.
    I removed the label property of the upload field and things worked as i wanted.

  • File Upload field wiht Camera option!

    Hi, I'm a web developer and I'd like to make my application accessible also from tablet. I tried the website with both default android Browser and Firefox browser; I saw that Firefox it is much more user friendly to touch and fast.
    In the website there is a form with a file upload field that is supposed to be used with images; the default android Browser gives the user the possibility to choose the camera, take the picture, and then select it for the upload. I'd like to know if there is the possibility to configure somewhere Firefox to add the Camera option with Astro and OpenOfficeDoc. Do you think is possible?
    Or do you know how this could be realized?
    Thank you in advance.
    Federica

    Interesting! I think there is a different site to offer feature suggestions for different Mozilla products, but I'm not sure where the Android one is. (I'm assuming that the option isn't available yet...)

  • Retain selected file on File Upload field

    I have a wizard consisting of 3 forms. The first form has a file upload field.
    The selected file name is not retained when i navigate from the first form to the second and then back again to the first form.
    I have tried to using javascript to record the selected filename in another field and then hoping that i can then repopulate the file upload 'text' box. However, this has failed as it appears that the file name selected is not the 'value' or 'text' of the file upload field.
    Any ideas?

    Some PC "windows" browsers need ".ogg" files in order to play.
    Just a heads up.
    I use jPlayer works on mac, Pc, & iOS
    http://jeffnitschke.com/Help.html

  • Unable to clear file upload fields in web pages.

    When visiting any site which has the option to upload a file, I am unable to clear the field if I change my mind about uploading a file.
    A website has a BROWSE or UPLOAD field and button. Pressing the button brings up the open file dialog. I select a file and select open in the dialog. If I then click on the field containing the path/file, I am presented with the open file dialog. I cannot clear or edit the field on the web page.
    I originally thought it was something with the web page I visited, but then found another page did the same thing.

    For instance if you go to this page again in Safari,
    http://www.apple.com/quicktime/qtv/mwsf06/
    and then select "View Source" from the View menu, then press command-f to "find" within the page and search for ".mov"
    You will find this, which shows the url of the movie itself.
    <param name="href" value="http://stream.qtv.apple.com/events/jan/mw2006/mmw_2006_650ref.mov">
    If you copy just this part:
    http://stream.qtv.apple.com/events/jan/mw2006/mmw_2006_650ref.mov
    And open QuickTime Player, go to the File menu, select "Open URL" the movie will play.
    If you try the same technique on the page at the link provided by your client, it will allow you to bypass the html code that may be doing an outdated compatibility check and the movie may play. Or it may tell you that you are missing components (codecs, compressors etc.) in which case, post here again.

  • Update File Upload Field

    Hi
    I have a file upload function in a "Update Record" form. I don't need to add new entries into the DB for each upload so I set the update to entered value 1.
    However on updating the record the file uploaded to the selected folder is deleted. Is it possible to update the same table field but not have the file deleted.
    If I upload fileA and then update id field 1 to upload fileB I do not want to delete fileA when I update id 1
    I hope that makes sense
    L

    Hi Albert
    I can't find any delete triggers in the code.
    ****CODE***
    //start Trigger_FileUpload trigger
    //remove this line if you want to edit the code by hand
    function Trigger_FileUpload(&$tNG) {
    $uploadObj = new tNG_FileUpload($tNG);
    $uploadObj->setFormFieldName("sfile_path");
    $uploadObj->setDbFieldName("sfile_path");
    $uploadObj->setFolder("../onlinemembership/supportdocs/");
    $uploadObj->setMaxSize(2000);
    $uploadObj->setAllowedExtensions("pdf, doc, txt");
    $uploadObj->setRename("auto");
    return $uploadObj->Execute();
    //end Trigger_FileUpload trigger
    // Make an update transaction instance
    $upd_support_file = new tNG_update($conn_DB_ACCESS);
    $tNGs->addTransaction($upd_support_file);
    // Register triggers
    $upd_support_file->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");
    $upd_support_file->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
    $upd_support_file->registerTrigger("END", "Trigger_Default_Redirect", 99, "file2-test.php");
    $upd_support_file->registerTrigger("AFTER", "Trigger_FileUpload", 97);
    // Add columns
    $upd_support_file->setTable("support_file");
    $upd_support_file->addColumn("sfile_path", "FILE_TYPE", "FILES", "sfile_path");
    $upd_support_file->setPrimaryKey("sfile_ID", "NUMERIC_TYPE", "VALUE", "1");
    // Execute all the registered transactions
    $tNGs->executeTransactions();
    ****END****
    Thanks
    L

  • I want to create a form in Muse with a file upload field

    I want to be able to have a form in which people can upload a file from my form which also provides information through other fields.
    this does not seem to be available through Muse. Can I use Muse for this type of field?

    Unfortunatly that sort of field is not yet available in Muse.
    A couple of ways that do work with Muse is to:
    1: host with Business CAtalyst and use their custom forms
    or
    2: Use Adobe Forms Central and embed the form into your muse site.
    Both of those work well.

  • File Upload field in livecycle designer

    Hi
    Am trying to create a form which allow user to add an attachment and want to display the size of the attached field.And also i wnt to save the form in the local system .Could anyone help me to come out of this.

    Niall O'Donovan wrote:
    Hi,
    Where a form is Reader Enabled in Acrobat, then the ability to attach other documents is restricted/not allowed:
    The ability to attach documents is ONLY available if the user has Acrobat OR if the form has been Reader Enabled in the full LC Reader Extensions ES2.5.
    See here: http://assure.ly/etkFNU.
    Hope that helps,
    Niall
    Hi Niall,
    Your answer and example is very helpful. I design a lot of forms with LiveCycle Designer ES2, and because of your answer here, I now know that the users of my forms will not be able to add attachments just by me "enabling Reader" from Acrobat.
    I have been trying to find what it would cost for me to have LiveCycle Reader Extensions. I spoke with an Adobe sales rep, and she didn't seem to understand the concept (that the user cannot upload attachments without Reader Extensions having enabled it). She said something about the cost starting @ $50,000. What!? Is she talking about the same thing I need? Then she directed me to contact Customer Service.
    I'm not sure who to turn to for my specific situation. I am the only one in my company using LiveCycle Designer and just need to enable a couple dozen people to be able to upload attachments to a form.
    Any advice would be appreciated.
    Regards,
    ZeroZone

  • How to add a field for multiple file upload in WebApps ?

    I am creating a WebApp for user to save some information with multiple pitcures. I can only see a single uploader.
    How can I add multiple image uploader and How can I create a custom file upload field rather than image upload ?

    Hi,
    There's no other upload field type for web apps.  You'll need to use the "image file type" to apply multiple file upload fields within the web app form in this case.
    Kind regards,
    -Sidney

  • File upload from smartphone?

    Currently your file upload field does not allow smartphone users to upload images/videos, any chance this may be possible soon?
    I used the following html5 coding on a separate site page and works well:
    <form action="server.cgi" method="post" enctype="multipart/form-data">
      <input type="file" name="video" accept="video/*" capture>
      <input type="submit" value="Upload">
    </form>
    Hoping this is also possible within your form but looks lke I'm not allowed to edit the form's html.
    Thanks for your help.
    Dave B

    This is something we are looking into. Can't say when it might be supported.
    Randy

  • File upload problem when form consists of more than 5 elements

              Hi,
              I noticed some bizarre behaviour that only occurs when going through an ssl proxy
              link to httpclusterservlet on our clustered environment, does not occur without
              ssl proxy.
              I have two different multipart forms One of them has:
              1.one file upload field and 7 other input fields
              The other one has:
              2.one file upload field and 2 other input fields
              Number 2 works as expected,
              but number 1-- it appears as if my servlet is called twice and the stream is corrupt--
              for example it starts of with the boundary, but after the fifth element half it
              gets cut off and then my servlet is called again with the remaining elements leaving
              off with where it was cut off.
              I don't think this is normal behaviour.
              Any ideas?
              

              Hi,
              I noticed some bizarre behaviour that only occurs when going through an ssl proxy
              link to httpclusterservlet on our clustered environment, does not occur without
              ssl proxy.
              I have two different multipart forms One of them has:
              1.one file upload field and 7 other input fields
              The other one has:
              2.one file upload field and 2 other input fields
              Number 2 works as expected,
              but number 1-- it appears as if my servlet is called twice and the stream is corrupt--
              for example it starts of with the boundary, but after the fifth element half it
              gets cut off and then my servlet is called again with the remaining elements leaving
              off with where it was cut off.
              I don't think this is normal behaviour.
              Any ideas?
              

  • Failed validation of file uploads makes them uneditable

    I have an issue with a file upload field (af:inputFile), such that if an error occurs on submission the error message is not modal and so the user can altar the values and reenable the OK button with an error message still visible.
    I was attempting to get around this since noone seemed to have a way to make the faces error messages modal (Is it possible  to make message popup with error messages modal?).
    I tried putting in a validator for the file... which works just fine (once you manage to actually clear the thing on cancel)... apart from the fact that once the validation fails the file name is shown as read only with an update button instead of a browse button. That update button then opens another dialog with a file upload in it and no matter what you do in this dialog the original one remains unchanged... and can be made visible if you move the new dialog off the top of it.
    Why can I not actually update the file? Why does it open a different dialog with a different input field that doesn't have my validator or binding or value? What can I do to get around this?
    I'm in ADF 11.1.1 but can use 12.1.2 if absolutely necessary for a fix. I don't use JDeveloper.
    Thank you.

    Thank you! Calling resetValue() on the file input component in the validator just before throwing ValidationException does the job!
    I've added the filename to my validation error message so that the user can still see which file it was they tried to upload and I think that solves all my issues

  • How to modify the field lengh of file upload

    Hi All,
       I am facing a problem with u201Cuploadu201D filed length in BSP application.
    When we upload the file in BSP page, the path displayed should be the full path (i.e. from where the file is being upload the file)
    Now this field is appearing 20 char length
    Now I want to increase the length of the upload field (Input field) to be 100 char so that the path is visible.
    In the current application the file upload is being done through a structure (attributes)
    In this structure the fields are like this
    PAGE_NAME
    ID
    FOR
    TAGS
    ROW_INDEX
    COLUMN_INDEX
    OTR_NAME
    REQUIRED_NAME
    MAXLENGTH
    SIZE
    TABLE_NAME
    ON_SELECT
    VALUE
    DISABLED
    ONCLICK
    TEXT
    TYPE
    Using this method:
    CALL METHOD cl_htmlb_fileupload=>factory
              EXPORTING
                Id      = ls_form_save-id
              RECEIVING
                Element = lv_fileup.
            bee_table->add ( level = 2 element = lv_fileup ).
    This cl_htmlb_fileupload is named as class interface.
    Which has the CLG_HTMLB_FILEUPLOAD (it is a class) it is defined in attributes.
    In this class it has the attribute u201CSIZEu201D by default string 20.
    Now I need to change this attribute length from 20 to 100
    For this I copied the standard class CL_HTMLB_FILEUPLOAD into ZCL_HTMLB_FILEUPLOAD.
    This ZCL_HTMLB_FILEUPLOAD contains all attributes of the standard class CL_HTMLB_FILEUPLOAD
    Including the one class (CLG_HTMLB_FILEUPLOAD), this is defined as an attribute (ABOVE MENTIONED?)
    This class is appearing in non editable mode, so   I have copied this class into zclass (ZCLG_HTMLB_FILEUPLOAD).but still I am not able to edit the attribute called u201Csizeu201D
    And also I am not bale to add the zclass in place of the ZCLG_HTMLB_FILEUPLOAD
    Kindly tell me how to modify the length of the field u201Csize u201Cand also how to add the zclass in the attributes of one class (syntax)
    Thanks in advance
    Rambabu.A

    Hi,
    Class CLG_HTMLB_FILEUPLOAD is a class automatically generated when a BSP Element is created. You should not change/create such a class, unless by creating your own BSP Element.
    As per your requirement, you can use the SIZE parameter of method factory:
    ls_form_save-size = '100'.
    CALL METHOD cl_htmlb_fileupload=>factory
    EXPORTING
    Id = ls_form_save-id
    Size = ls_form_save-size
    RECEIVING
    Element = lv_fileup.
    Regards,
    Tanguy

  • Cmd+v doesn't paste in the file upload dialogue's search field in Safari

    In Safari 4.0.4 on OS X 10.6.2, cmd+v doesn't paste in the file upload dialogue's search field in Safari. It just makes an audio beep to indicate an error.
    Using a sample file uploader:
    1.) Visit http://upload.youtube.com/myvideosupload
    2.) Click the "Upload Video" button.
    3.) Select file(s) to upload to s.ytimg.com
    4.) Click on the search text field
    *5.) Cmd+V to paste text. Nothing happens.*
    However, if you right-click, "Paste" is not grayed out, and you can paste normally.
    This is for version 4.0.4, but this behavior has been present for as long as I can remember using Safari.
    Can anyone confirm this bug?

    HI,
    I can't confirm a bug but you can report it.
    From the Safari Menu Bar click Safari/Report Bugs to Apple.
    Carolyn

Maybe you are looking for

  • 12 volt charging plug

    I have an HP Laptop and would like to be able to plug it into a standard 12 volt DC outlet. I have checked several computer stores for this type of plug in device and no one has them. My sailboat has many 12 volt outlet receptacles connected to a lar

  • Create orders in CRM with repetitive CRM_ORDER_MAINTAIN remote calls

    Dear All, Though we all must have done a lot of playing around with CRM but I am sure that a lot of us would find this as a tricky one. We know that CRM Web-UI framework at the back-end is actually a repetitive, Remote call framework to CRM APIs and

  • 0 bytes file free on curve 8320??

    All, Please help, I got stuck with my 8320. Device is "thinking" very often and impact to my activities and also the battery. When I check Status on option, File free is 0 bytes.. but when i restart (take off the batt), file free is have some bytes a

  • Acknowledgment of receipt expected and not Read acknowledgment expected

    Hi everybody, In the SAP structure SOOS1 we have the fields DELIVER and READ to set the Acknowledgment of receipt expected and the Read acknowledgment expected. When i try to set only the DELIVER field ='X', the system send me the Acknowledgment of r

  • Location Services Always on in 7.1?

    Does anyone else notice that the little 'Location Services' arrow at the tope of the screen is always on after they updated to OS 7.1? Does this mean more battery life will be drained? I have tried closing all of my open apps and re-starting the phon