0

I am using tiny mce to upload images to a server, I need help with writing the image upload handler for it. This is what I have so far: TinyMce script -

tinymce.init({
    selector: "textarea",
    height: 450,
    theme: "modern",
    paste_data_images: false,
    plugins: "table,link,textcolor,lists,image"
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    images_upload_url: 'handleImageUpload.asp',
    automatic_uploads: true,
    file_picker_types: 'image',
    file_picker_callback:function (cb, value, meta) {
            var input = document.createElement('input');
            input.setAttribute('type', 'file');
            input.setAttribute('accept', 'image/*');
            input.onchange = function () {
                var file = this.files[0];
                var reader = new FileReader();
                reader.onload = function () {                   
                    var id = 'blobid' + (new Date()).getTime();
                    var blobCache = tinymce.activeEditor.editorUpload.blobCache;
                    var base64 = reader.result.split(',')[1];
                    var blobInfo = blobCache.create(id, file, base64);
                    blobCache.add(blobInfo);

                    /* call the callback and populate the Title field with the file name */
                    cb(blobInfo.blobUri(), { title: file.name });
                };
                reader.readAsDataURL(file);
            };

            input.click();
        },

And my handleImageUpload.asp so far goes like this -

<%@  language="VBScript" %>
<% option explicit %>

<%
dim fs,f,sFiles
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateFolder(Server.MapPath("/images"))
sFiles = Request.Files("file")

%>

The issue is Request.Files("file") doesn't return the image data that is to be uploaded. Any help will be appreciated.

Thanks.

pankaj
  • 185
  • 1
  • 2
  • 10
  • There's no such collection called `Request.Files` in Classic ASP you need to take the raw binary sent by the uploader using `Request.BinaryRead()` and parse the binary yourself or use an upload component like [ASPUpload](http://www.aspupload.com/). There are also some [custom classes](https://stackoverflow.com/a/12200970/692942) that facilitate this, best not trying to re-invent the wheel. – user692942 May 13 '20 at 12:29
  • @Lankymart - There is an example of how to write the image upload handler on tiny mce website but it is in PHP. I need to write something similar in classic ASP but I am very new to it so need some help on it. This is the php example I am talking about - [link](https://www.tiny.cloud/docs/advanced/php-upload-handler/) – pankaj May 13 '20 at 16:34
  • Look at the duplicate it’s not as straight-forward as php to implement a custom uploader. I’ve already advised you on your options, did you have a look at the top voted answer on the duplicate? You’ll find it is very comprehensive. – user692942 May 13 '20 at 17:48

0 Answers0