MyBB Community Forums

Full Version: Uploads.im upload
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
1 - Create im.php in root

<html>
<head>
<title>Upload to Uploads.im</title>
</head>
</html>
<div><img src="images/imlogo.png" border="0" /></div>
<br /><br />
<button onclick="document.querySelector('input').click()">Select file...</button>
<input style="visibility:hidden;position:absolute;top:0;" type="file" onchange="uploadim(this.files[0])">

<script>
    function uploadim(file) {

        /* Is the file an image? */
        if (!file || !file.type.match(/image.*/)) return;

        /* It is! */
        document.body.className = "uploading";

        /* Lets build a FormData object*/
        var fd = new FormData(); // I wrote about it: https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
        fd.append("upload", file); // Append the file
        var xhr = new XMLHttpRequest(); // Create the XHR (Cross-Domain XHR FTW!!!) Thank you sooooo much imgur.com
        xhr.open("POST", "http://uploads.im/api"); // Boooom!
        xhr.onload = function() {
            var code = '[img]' + JSON.parse(xhr.responseText).data.img_url + '[/img]';
            var editor = eval('opener.' + 'clickableEditor');
            editor.performInsert(code);
            javascript:window.close()
        }
        // Ok, I don't handle the errors. An exercice for the reader.
        /* And now, we send the formdata */
        xhr.send(fd);
    }
</script>

<style>
    body {text-align: center; overflow-x:hidden; overflow-y:auto;}
    div { border-bottom: 4px solid rgb(68, 68, 66); margin: -8px;}
    p {display: none}
    .uploading p {display: inline}
</style>
<br /><br />
<p><img src="images/preload.gif" border="0" /></p> 


2 - Copy preload.gif [attachment=30953] and imlogo.png [attachment=30954] in images folder of your mybb installation.

3 - Copy im.png [attachment=30955] in jscripts/editor_themes/default/images/ and jscripts/editor_themes/office2007/images/

4 - Open jscripts/editor.js

4.1 - Find

{type: 'button', name: 'img', sprite: 'image', insert: 'image', extra: 1, title: this.options.lang.title_image},

4.2 - Add after

{type: 'button', name: 'im', insert: 'im', image: 'im.png', title: 'Upload to Uploads.im'},

4.3 - Find

insertIMG: function()
	{
		image = prompt(this.options.lang.enter_image, "http://");

		if(image)
		{
			this.performInsert("[img]"+image+"[/img]", "", true);
		}
	},

4.4 - Add after

insertIm: function()
	{
		MyBB.popupWindow('im.php', 'im', 240, 200);
	},

4.5 - Find

case "image":
				this.insertIMG();
				break;

4.6 - Add after

case "im":
				this.insertIm();
				break;
Thx!
Obrigado. Mas upload de arquivos em servidores como o Mega ou dropbox?
@dthiago

is out of my reach.
I can not help you with that ...
may be possible to make with much effort to mediafire or rapidshare, but at the moment I do not have that patience. Not to mention that I'm noob in programming.
(2014-02-02, 04:26 AM)martec Wrote: [ -> ]@dthiago

is out of my reach.
I can not help you with that ...
may be possible to make with much effort to mediafire or rapidshare, but at the moment I do not have that patience. Not to mention that I'm noob in programming.

@martec ..ok Obrigado.Thx
nice sir... but its posible to have a file uload also?