Jump to content

Oliver Morsch

uniGUI Subscriber
  • Posts

    356
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Oliver Morsch

  1.  
         UniImage.Picture.Graphic := TJPEGImage.Create
    

     

    Could this produce a memory leak? I Think so, if i read this note from embarcadero:

     

    Note: When assigning the Graphic property, TPicture assigns the properties of a another TGraphic object. It does not take ownership of the specified object.

     

    TPicture seems to use assign to make a copy (and not take ownership) of the created JpegImage-Object so that this is never be freed?!

  2. What filetype (.bmp, .jpg, .png, ...) do you upload and do you really want to save it as Bitmap?

     

    You should delete "BS.Free;".

     

    What if you use field type ftBlob instead of ftGraphic?

  3. <script type="text/javascript">
     
    function success(position) {
     alert(position.coords.latitude + ' / ' + position.coords.longitude);
    }
     
    function error(msg) {
     alert('failed');
    }
     
     
    if (navigator.geolocation) {
     navigator.geolocation.getCurrentPosition(success, error);
    } else {
     alert('not supported');
    };
     
    </script>
    

  4. With the new dropbox UI you can upload a file just with drag and drop.

     

    That is using HTML5 and works with UniGui too (in Firefox, Chrome and maybe other).

     

    With this Code you can drag'n'drop files from Windows Explorer to the Upload-division in your website. The (picture-)file will be displayed below; everything on Clientside:

     

    Link

     

    Adding this code allows you to upload the files to server:

     

    Link

     

    But my question to Farshad: Is there a size limit for params in ajaxRequest?

  5. (Uni)FileUpload uses something like:

     

    <form method="post" enctype="multipart/form-data">
     <input name="Datei" type="file">
    </form>

     

    And modern browsers don't let you change anything (like the "value" attribute) of <input type="file">. The browser lets the user choose a file and only just this will be uploaded for security reasons.

     

    Since the Files you got are already been base64-encoded, you could easy use something like:

     

    ajaxRequest(MyForm.MyComponent, 'SendFile', ['FileContent='+evt.target.result]);
    //(where evt.target.result is the base64-encoded-file you got, see other thread)

     

    in Delphi you need then something like:

     

    procedure TMyForm.MyComponentAjaxEvent(Sender: TComponent; EventName: string; Params: TStrings);
    begin
     if EventName='SendFile' then begin
       //Params.Values['FileContent']; contains the base64-encoded data
       //it should be no problem to decode it here in delphi on server
       //...
     end;
    end;
    

  6. simply put this code in an UniHtmlFrame:

     

    <script type="text/javascript">
    
    
    function dragEnter(evt) {
     evt.stopPropagation();
     evt.preventDefault();
    }
    
    function dragExit(evt) {
     evt.stopPropagation();
     evt.preventDefault();
    }
    
    function dragOver(evt) {
     evt.stopPropagation();
     evt.preventDefault();
    }
    
    function drop(evt) {
     evt.stopPropagation();
     evt.preventDefault();
     var files = evt.dataTransfer.files;
     var count = files.length;
     // Only call the handler if 1 or more files was dropped.
     if (count > 0)
       handleFiles(files);
    }
    
    
    function handleFiles(files) {
     var file = files[0];
     document.getElementById("droplabel").innerHTML = "Processing " + file.name;
     var reader = new FileReader();
     // init the reader event handlers
     reader.onload = handleReaderLoad;
     // begin the read operation
     reader.readAsDataURL(file);
    }
    
    
    function handleReaderLoad(evt) {
     var img = document.getElementById("preview");
     img.src = evt.target.result;
    }
    
    
    function initEventHandlers() {
     var dropbox = document.getElementById("dropbox")
     dropbox.addEventListener("dragenter", dragEnter, false);
     dropbox.addEventListener("dragexit", dragExit, false);
     dropbox.addEventListener("dragover", dragOver, false);
     dropbox.addEventListener("drop", drop, false);
    }
    
    </script>
    
    
    <div id="dropbox" style="background-color: #00AAFF; height: 40px">
    <span id="droplabel">Drop file here...</span>
    </div>
    
    <br/>
    
    <img id="preview" src="" alt="[ preview will display here ]" />
    
    
    <script type="text/javascript">
    initEventHandlers();
    </script>
    
    

  7. I have an UrlFrame with the id "myUrlFrame" and a "div" on it with the name "myTile3". To get the text of this element, I use the following code:

     

    document.getElementById('myUrlFrame').contentWindow.document.getElementById('myTile3').firstChild.data;

     

    But the server and port must be exactly the same; Browsers deny access for security reasons, if you use another servername or port.

  8. When I make standalone server application it works correctly, but in isapi module error occurs:

    Project1: 000008FC: 10:59:03:Exception : None of the dynamic libraries can be found: libmysql51.dll, libmysql50.dll, libmysql.dll

     

    Are the dll's located in the app-path? Then standalone server finds the dll's in its path, but in case of isapi the searchpath is the path of the internetserver (iis, apache).

×
×
  • Create New...