diff --git a/sms-conversations/css/style.css b/sms-conversations/css/style.css index 70781ed..6b1131d 100644 --- a/sms-conversations/css/style.css +++ b/sms-conversations/css/style.css @@ -146,3 +146,12 @@ clear: both; height: 0; } + +#media-url { + padding-left:5px; + cursor: pointer; +} + +.fa-paperclip:hover { + cursor: hand; +} diff --git a/sms-conversations/js/index.js b/sms-conversations/js/index.js index 23db5e6..9015f9c 100644 --- a/sms-conversations/js/index.js +++ b/sms-conversations/js/index.js @@ -211,8 +211,7 @@ $(document).ready(function(){ $('#sendSMS').click(function(e) { e.preventDefault(); - - $.post(OpenVBX.home + "/messages/sms/" + $('#sms-messageid').val(),{to:$('#sms-to-phone').val(),from:$('#sms-from-phone').val(),content:$('#message-to-send').val()}, function( data ) { + $.post(OpenVBX.home + "/messages/sms/" + $('#sms-messageid').val(),{to:$('#sms-to-phone').val(),from:$('#sms-from-phone').val(),content:$('#message-to-send').val(),media_urls:$('#sms-media-url').val()}, function( data ) { if(!data.error) { $('#message-to-send').val(''); @@ -225,6 +224,35 @@ $(document).ready(function(){ setTimeout(function() { getSmsHistory($('#sms-to-phone').val()); }, 1500); }); + $("#media-url").click(function() { + + document.getElementById("sms-media-url").click(); + + return false; // avoiding navigation + }); + + $('#sms-media-url').change(function(evt) { + var formData = new FormData(document.getElementById("sms-media-url")); + formData.append('action','mms-file-upload'); + + $.ajax({ + url: 'sms-conversation', + type: 'POST', + async: true, + enctype: 'multipart/form-data', + processData: false, // tell jQuery not to process the data + contentType: false, // tell jQuery not to set contentType + data: formData, + error: function(){ + console.log("error"); + }, + success: function(data){ + console.log("PHP Output:"); + console.log( data ); + } + }); + }); + $('.quick-call-button').click(function(e) { e.preventDefault(); diff --git a/sms-conversations/mms-files/logo.jpg b/sms-conversations/mms-files/logo.jpg new file mode 100644 index 0000000..7c23fdb Binary files /dev/null and b/sms-conversations/mms-files/logo.jpg differ diff --git a/sms-conversations/sms-conversation.php b/sms-conversations/sms-conversation.php index 95406dc..212c410 100644 --- a/sms-conversations/sms-conversation.php +++ b/sms-conversations/sms-conversation.php @@ -31,6 +31,12 @@ $mediaObj = $ci->twilio->request($media_url, "GET"); echo $mediaObj->ResponseText; + exit; + } + else if($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['action'] === 'mms-file-upload') { + //var_dump($_FILES, $_POST); + echo '{"url":"http://test.com"}'; + exit; } @@ -86,7 +92,9 @@
+ +