Jump to content

beanymanuk

Members
  • Posts

    107
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.peter-gosling.com

Profile Information

  • Gender
    Male

beanymanuk's Achievements

Regular Member

Regular Member (3/5)

1

Reputation

  1. Hi Ultimate Aim: To upload multiple images using ajax using a PHP script which will be fired once an image is selected and then return the resulting URL for use in rest of my JS http://peter-gosling.com/testupload/chooseimage.html simple form posts to http://peter-gosling.com/testupload/saveimage.php This PHP script below currently gets the posted image and assigns it a random number file name and echos this <?php header("Access-Control-Allow-Origin: *"); $uploaddir = '/home/petergos/public_html/testupload/images/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); $urlpath = "http://www.peter-gosling.co.uk/testupload/images/"; $temp = explode(".",$_FILES["userfile"]["name"]); $newfilename = rand(1,999999999) . '.' .end($temp); $newuploadfile = $uploaddir . $newfilename; echo "<p>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $newuploadfile)) { $urlfile = $urlpath . $newfilename; echo $urlfile; } else { echo "Upload failed"; } ?> What I want to do is post my image via ajax but return the value back to my js file I'm not certain on the CORS issue Here's my first attempt http://peter-gosling.com/testupload/ HTML <!DOCTYPE html> <html> <head> </head> <body> <input type="file" accept="image/*;capture=camera" name="taskoutputfile"></input> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> $("input[name=taskoutputfile]").on("change", function (){ var fileName = $(this).val(); console.log(fileName); get_image_url(fileName) }); //UPLOAD IMAGE RETURN URL function get_image_url(imageurl) { var dataString = "url="+imageurl; //datastring = $("input[name=sessiontitle]").val(); //AJAX code to submit form. $.ajax({ type: "POST", url: "http://www.peter-gosling.co.uk/testupload/saveimage2.php", data: dataString, cache: false, success: function(html) { alert(html); } }); } </script> </body> </html> PHP <?php header("Access-Control-Allow-Origin: *"); $uploaddir = '/home/petergos/public_html/testupload/images/'; $uploadfile = $uploaddir . basename($_POST['url']); $urlpath = "http://www.peter-gosling.co.uk/testupload/images/"; $temp = explode(".",$_POST['url']); $newfilename = rand(1,999999999) . '.' .end($temp); $newuploadfile = $uploaddir . $newfilename; echo "<p>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $newuploadfile)) { $urlfile = $urlpath . $newfilename; return $urlfile; } else { echo "Upload failed"; } /* echo "</p>"; echo '<pre>'; echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; */ ?> Have attached all files Any help would be really appreciated Thankyou
  2. No errors reported when sending at all So I believe its something to do with hosting blocking .co in particular from sending emails
  3. email address on .co domain is setup as a google apps email and I have tried sending to my .com google apps email and that works ok
  4. PHP mail not sending emails to .co domain email addresses Anyone got any experience or advice on this issue? I don't know what to try or do about it
  5. How can I retrieve the latest tweets for multiple users on Twitter and display them in one feed? I can only seem to find ways to pull one account using the API v1.1 How do I go about doing this?
  6. Hi Having issues on this page in IE 7/8 where the slider isn't working works in IE 9/10 and other browsers There is an error showing in IE 7 / 8 but I'm unsure of how to fix this SCRIPT65535: Unexpected call to method or property access. jquery.min.js, line 2 character 66529 http://gamerservices.co.uk/flexslider/ Thanks in advance
  7. Hi I am trying to make a menu move from being a 4 by 2 (with each block size calculated to fit 100% width) menu docked at the bottom of the page then once any link is clicked in that menu for it to move nicely across the page to be docked on the right hand side of the page in one column (each block resized in height so the total height of the blocks fit 100% height of the users browser window) Hope that makes sense. This is what I have so far showing basic concept of menu View Menu here Any help greatly appreciated Thanks
  8. Found the problem //wrong way round array_multisort($results, SORT_DESC, $amounts); //right way round array_multisort($amounts, SORT_DESC, $results);
  9. Hi Code <?php $xml=simplexml_load_file("http://www.peter-gosling.com/testxml.xml"); foreach($xml->accumulator as $accumulator) { if(($accumulator->currency == 'GBP') && (($accumulator->game_id == 'PF') || ($accumulator->game_id == 'ST') || ($accumulator->game_id == 'TO2') || ($accumulator->game_id == 'LO2') || ($accumulator->game_id == 'KQ'))) { $results[] = (array)$accumulator; $amounts[] = (array)$accumulator->amount; } } //print_r($results); array_multisort($results, SORT_DESC, $amounts); $top4 = array_slice($results, 0, 4); print_r($top4); ?> So I want Top 4 games out of the 5 games I'm pulling out based on the amount
  10. Thats not quite right not sorting correctly so not getting the highest 4 results Array before sort Array ( [0] => Array ( [game_id] => G1 [currency] => GBP [game] => G1 [game_type] => midlet [amount] => 111830 [display_amount] => £1,118.30 ) [1] => Array ( [game_id] => G2 [currency] => GBP [game] => G2 [game_type] => midlet [amount] => 23831 [display_amount] => £238.31 ) [2] => Array ( [game_id] => G3 [currency] => GBP [game] => G3 [game_type] => midlet [amount] => 38963 [display_amount] => £389.63 ) [3] => Array ( [game_id] => G4 [currency] => GBP [game] => G4 [game_type] => midlet [amount] => 86691 [display_amount] => £866.91 ) [4] => Array ( [game_id] => G5 [currency] => GBP [game] => G5 [game_type] => midlet [amount] => 25000 [display_amount] => £250.00 ) ) I am getting result in order G5, G2, G1, G4 When result should be G1, G4, G3, G5
  11. I've got it in simple xml but not sure about the filtering bit any help I've tried this so far $xml = array_filter($xml, function($obj){ if (isset($obj->accumulator)) { foreach ($obj->accumulator as $accumulators ) { if ($accumulators->currency != 'GBP') return false; } } return true; });
  12. Hi this is what I want to do Read values from xml into two dimensional array and then filter out ones with currency GBP and then sort by amount DESC and output the top 4 results I can get xml into php ok but I don't know how to loop those results into an array and then do the rest. Any help would be muchly appreciated Thanks EG of XML <accumulators> <accumulator> <game_id>Test</game_id> <currency>EUR</currency> <game>Test</game> <game_type>midlet</game_type> <amount>22269</amount> <display_amount>€222.69</display_amount> </accumulator> <accumulator> <game_id>Test2</game_id> <currency>GBP</currency> <game>PharaohsFortunesSlots</game> <game_type>midlet</game_type> <amount>6348</amount> <display_amount>£63.48</display_amount> </accumulator> </accumulators>
  13. I am trying to output my javascript array so it works in a slider But its not outputting at the correct time I think so that the slider Jquery affects that div Any ideas on where I am going wrong? <!DOCTYPE html> <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]--> <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]--> <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]--> <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]--> <head> <meta charset="utf-8"> <title>Slider</title> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script> <script src="http://www.flashuser.net/tutorial/jquery-image-grid/js/jquery.flexslider-min.js" type="text/javascript"></script> <script src="http://www.flashuser.net/tutorial/jquery-image-grid/js/prettyphoto/js/jquery.prettyPhoto.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('.flexslider').flexslider({ animation: "slide", slideshow: true, slideshowSpeed: 7000, animationSpeed: 600, prevText: 'Prev', nextText: 'Next' }); $(".slides li:not(.clone) a[rel^='prettyPhoto']").prettyPhoto({ animation_speed: 'normal', autoplay_slideshow: true, slideshow: 3000 }); }); </script> <style> .usernamenamelabel { width:100px; float:left; font-size:13px; } .flex-control-nav { display:none; } #wrap, #wrap2{ width:366px; clear:both; } </style> </head> <body> <script type="text/javascript"> window.onload = function() { var str = "test1,test2,test3,test4,test5,test6, test7, test8, test9, test10 ,test11, test12, test13,test14,test15,test16,test17,test18,test19"; var temp = new Array(); // split string put into an array temp = str.split(","); var tt = temp.length; var tt2 = tt % 9; var tt3 = 9 - tt2; //document.write(tt3); for (var ai = 0; ai < tt3; ai++) { temp.push(""); } var att = temp.length; var result = "<section class='flexslider'><ul class='slides'><li><div class='row'>"; for (var i = 0; i < att; i++) { result += "<div class='usernamenamelabel'>"+temp[i]+"</div>"; if (i % 9 == { result += "</div></li>"; if(i !=(att-1)) { result += "<li><div class='row'>"; } } else { if (i % 3 == 2) { result += "</div><div class='row'>"; } } } result += "</ul></section></div>"; //document.write(result); document.getElementById("wrap2").innerHTML = result; } </script> <div id="wrap2"></div> <div id="wrap"> <section class="flexslider"> <ul class="slides "> <li> <div class="row"> <div class="usernamenamelabel">test1</div> <div class="usernamenamelabel">test2</div> <div class="usernamenamelabel">test3</div> </div><!--end row--> <div class="row"> <div class="usernamenamelabel">test4</div> <div class="usernamenamelabel">test5</div> <div class="usernamenamelabel">test6</div> </div><!--end row--> <div class="row"> <div class="usernamenamelabel">test7</div> <div class="usernamenamelabel">test8</div> <div class="usernamenamelabel">test9</div> </div><!--end row--> </li> <li> <div class="row"> <div class="usernamenamelabel">test10</div> <div class="usernamenamelabel">test11</div> <div class="usernamenamelabel">test12</div> </div><!--end row--> <div class="row"> <div class="usernamenamelabel">test13</div> <div class="usernamenamelabel">test14</div> <div class="usernamenamelabel">test15</div> </div><!--end row--> <div class="row"> <div class="usernamenamelabel">test16</div> <div class="usernamenamelabel">test17</div> <div class="usernamenamelabel">test18</div> </div><!--end row--> </li> <li> <div class="row"> <div class="usernamenamelabel">test19</div> <div class="usernamenamelabel">test20</div> <div class="usernamenamelabel">test21</div> </div><!--end row--> <div class="row"> <div class="usernamenamelabel">test22</div> <div class="usernamenamelabel">test23</div> <div class="usernamenamelabel">test24</div> </div><!--end row--> <div class="row"> <div class="usernamenamelabel">test25</div> <div class="usernamenamelabel">test26</div> <div class="usernamenamelabel">test27</div> </div><!--end row--> </li> </ul> </section><!--end flexslider--> </div><!--end wrap--> </body> </html>
  14. I'm just getting "error" not very helpful Heres my latest code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <title>My jQuery JSON Web Page</title> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript"> JSONTest = function() { var resultDiv = $("#resultDivContainer"); var girlID = 1124 var searchString = '' $.ajax({ //contentType: "application/json; charset=utf-8", url: "http://www.fhm.com/site/pages/girls/100sexiest2010/VotePopup.aspx/InsertVote", type: "POST", data: { girlId:1124,girlName:'', shareType:3 }, //data: "{girlId:" + girlId + ",girlName:'" + searchString + "', shareType:3}", dataType: "json", error: function (xhr, status, error) { //j$("#voteError").show("slow"); alert(xhr.statusText); alert(error); }, success: function (voteid) { switch (result) { case true: processResponse(voteid); break; default: resultDiv.html(voteid); } } }); }; </script> </head> <body> <input type="hidden" id="ctl00_Body_VotingPanel_hidSearchString" name="ctl00$Body$VotingPanel$hidSearchString"> <h1>My jQuery JSON Web Page</h1> <div id="resultDivContainer"></div> <button type="button" onclick="JSONTest()">JSON</button> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.