Jump to content

oddball25

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by oddball25

  1. Solved with: $values = array(); foreach ($_SESSION['all'] as $car) { $values[] = $car['value']; } $cheapest = min($values);
  2. Hi I am having trouble using the min() function to find the lowest value within my session arrays. On my site i have the following car values saved into my $car array: $car = array( "itemNumber" => $itemNumber, "Model" => $Model, "EngineSize" => $EngineSize, "Colour" => $Colour, "Value" => $Value, ); I then store each $item array into a $_SESSION['all'] as below: if (isset($_SESSION['all'])) { $_SESSION['all'][$number] = $car; } else { $_SESSION['all'] = array($number => $car); } Now i need to find the lowest Value of all the cars that the user may add. I have been using the min() function to try and do this with the following code but it gives me the error: Wrong parameter count for min()..... $cheapest = min($car['Value']); Am i on the right tracks or is this not possible? If anyone could shed some light on how i can get this to work, would be very much appreciated!
  3. Thanks for the link, have just used it in my code and it works perfectly thanks!
  4. Hi I am having some problems with my mysql database and php queries. I have a simple table ('database_table') that stores order details from my online gift shop. The table is set up as follows: id | order_code | item_code | item_description | name --------------------------------------------------------------------- 1 | 56743 | 56AAY | Fruit Bowl | Joe 2 | 56743 | 518VB | Aftershave | Joe 3 | 88932 | 11TQW | Red Mug | Mary etc... Each item (defined by item_code and item_description) within the order will be added to a separate row. On orders such as '56743' (Joe), there are two entries as they have ordered 2 items within the 1 order. Now my problem is that i want to set up a query that pulls order '56743' from the database and displays all the items within the order. I have the following PHP code for my query: $query="SELECT * FROM database_table WHERE order_code='56743'"; $result=mysql_query($query); mysql_close(); while($row = mysql_fetch_array($result)) { echo " <p>Your Order:</p> <p>Your Name: ".$row['name']."</p> <p>Your Order Code:".$row['order_code']."</p> <p>Your Item Codes:".$row['item_code']."</p> <p>Your Item Descriptions:".$row['item_description']."</p>"; } This outputs the following: Your Order: Your Name: Joe Your Order Code: 56743 Your Item Codes: 56AAY Your Item Descriptions: Fruit Bowl Your Order: Your Name: Joe Your Order Code: 56743 Your Item Codes: 518VB Your Item Descriptions: Aftershave But i only want it to output the 'item_code' and 'item_description' more than once if the order has several items, The 'name' and 'order_code' i only want to be displayed once (so as below:) Your Order: Your Name: Joe Your Order Code: 56743 Your Item Codes: 56AAY Your Item Codes: 518VB Your Item Descriptions: Fruit Bowl Your Item Descriptions: Aftershave I am quite new to mysql so apologies if this isn't explained to well and for the length of it! Thanks in advance for any help John
  5. Hi I have an masked image that is externally loaded onto my stage that the user can drag and position. I then need to be able to record or save where and how the user has positioned the image by either -taking a bitmap copy of where the user has positioned the image (my first and easiest thought of how to do this) -or is it possible to get X and Y co ordinates of where they have positioned it I have a movie currently set up but when the user clicks 'save and continue' it takes a copy of the original position of the image - not from where you have last dragged it to, any ideas? Full code and attached fla file below Many thanks for any help in advance stop(); //-------------- // Loader //-------------- var imageP1:Loader = new Loader(); var request:URLRequest = new URLRequest('http://www.tiltworld.co.uk/TH785RFD/image.jpg'); imageP1.load(request); addChild(imageP1); imageP1.x=100; imageP1.y=100; var image_Content:Sprite = new Sprite(); var imageP1_Content:Sprite = new Sprite(); image_Content.buttonMode=true; imageP1_Content.addChild(imageP1); image_Content.addChild(imageP1_Content); addChild(image_Content); // //-------------- // Start Up Mask //-------------- imageP1.mask=landscape_masks.landscape_mask_10x8; // //-------------- // Drag //-------------- imageP1.addEventListener(MouseEvent.MOUSE_DOWN, drag); stage.addEventListener(MouseEvent.MOUSE_UP, drop); function drag(event:Event):void { image_Content.startDrag(); } function drop(event:Event):void { image_Content.stopDrag(); } // //-------------- // Continue //-------------- continue_btn.addEventListener(MouseEvent.MOUSE_DOWN, contin); function contin(event:Event):void { bitmapCopy(); } // //-------------- // Bitmap Copy Function //-------------- function bitmapCopy() { var bd:BitmapData = new BitmapData(450, 400); bd.draw(imageP1_Content); var b:Bitmap = new Bitmap(bd); addChild(b); b.x=5; b.y=480; } // [attachment deleted by admin]
  6. Hi I have a startDrag function set up on a loader and mask that when the mouse is down on the loader it drags, when not it doesn't. There is also 2 buttons that control whether mask1 or mask2 is used. What i would like however is when the mouse is down - the area of the loader outside of the mask is visible but only by about 10/20% alpha, that way the user can see where all the image is while dragging. Is this possible? I have the swf set up on the following link: http://www.tiltworld.co.uk/TH785RFD/myDrag.swf Full code can be seen below and i have attached the zip with the .fla file: // Imports. import flash.display.Sprite; // // Sets masks as false on start up. maskP1.visible = false; maskP2.visible = false; // // Load External Image into loader. var imageP1:Loader = new Loader(); var request:URLRequest = new URLRequest("http://www.tiltworld.co.uk/TH785RFD/image.jpg"); imageP1.load(request); addChild(imageP1); imageP1.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete); function onLoadComplete(event:Event):void { imageP1.x = 67; imageP1.y = 67; imageP1.width = 425; imageP1.height = 282; } // // Make Loader a Child of Sprite. var imageP1_Content:Sprite = new Sprite(); imageP1_Content.buttonMode = true; imageP1_Content.addChild(imageP1); addChild(imageP1_Content); // // Set Drag Function. imageP1.addEventListener(MouseEvent.MOUSE_DOWN, drag); imageP1.addEventListener(MouseEvent.MOUSE_UP, drop); function drag(event:Event):void { imageP1_Content.startDrag(); } function drop(event:Event):void { imageP1_Content.stopDrag(); } // // Set functions for mask scale. _10x10.addEventListener(MouseEvent.MOUSE_UP,scale1); _20x20.addEventListener(MouseEvent.MOUSE_UP,scale2); function scale1 (event:Event):void { maskP1.visible = true; maskP2.visible = false; imageP1.mask = maskP1; } function scale2 (event:Event):void { maskP2.visible = true; maskP1.visible = false; imageP1.mask = maskP2; } // Please, please help! Thanks in advance John [attachment deleted by admin]
  7. Hey Having a problem trying to get the external interface working with as3. My flash file has 2 input text boxes with instances of 'received_ti' and 'sending_ti' and a button with instance of 'send_button'. My html code has a simple form with 'sendField' and 'receivedField' inputs and a submit with a value of 'Send'. At the moment i can get the flash file to send text into the html 'receivedField' input but cannot send text from html into the flash file's 'received_ti' text box. Can anyone help me out with this? I am really struggling... My full code is below: Flash AS3: import flash.external.ExternalInterface; import flash.events.Event; ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript); send_button.addEventListener("click", clickSend); function getTextFromJavaScript(str:String):void { received_ti.text = "From JavaScript: " + str; } function clickSend(event:Event):void { var jsArgument:String = sending_ti.text; var result:Object = ExternalInterface.call("getTextFromFlash", jsArgument); received_ti.text = "Returned: " + result; } HTML & Javascript: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Upload Start</title> <script src="Scripts/swfobject_modified.js" type="text/javascript"></script> <script type="text/javascript"> function getFlashMovie(movieName) { var isIE = navigator.appName.indexOf("Microsoft") != -1; return (isIE) ? window[movieName] : document[movieName]; } function formSend() { var text = document.htmlForm.sendField.value; getFlashMovie("UploadStart").sendTextToFlash(text); } function getTextFromFlash(str) { document.htmlForm.receivedField.value = "From Flash: " + str; return str + " received"; } </script> </head> <body> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="964" height="510" id="UploadStart"> <param name="movie" value="Upload_Start.swf" /> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="swfversion" value="6.0.65.0" /> <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. --> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. --> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="Upload_Start.swf" width="964" height="510" id="UploadStart"> <!--<![endif]--> <param name="quality" value="high" /> <param name="wmode" value="opaque" /> <param name="swfversion" value="6.0.65.0" /> <param name="expressinstall" value="Scripts/expressInstall.swf" /> <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. --> <div> <h4>Content on this page requires a newer version of Adobe Flash Player.</h4> <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p> </div> <!--[if !IE]>--> </object> <!--<![endif]--> </object> <form name="htmlForm" method="POST" action="javascript:formSend();"> Sending to ActionScript:<br /> <input type="text" name="sendField" value="" /><br /> <input type="submit" value="Send" /><br /> <br /> Received from ActionScript:<br /> <input type="text" name="receivedField"/> </form> </body> </html> Many thanks John
  8. Hi Wondering if you guys can help. I have been asked to develop an image upload flash application that also allows you to fully edit the uploaded image by someone, i have a rough idea of as2 and as3 coding but this looks pretty indepth. I have attached an image and the link of 2 editors that are currently online that do a very similar job to what i am after. The image is shown on a canvas 'net' with the image overlaid on top where the user can drag/scale/rotate the image, plus if the user changes the size of the canvas the sides of the canvas 'net' adjust to suit. Flash Editor 1.png attachment (link below) https://www.yourimage2canvas.co.uk/secure/photos-to-canvas.php Flash Editor 2.png attachment (link below) http://www.point101.com/print_your_photos/#/upload Now i am still trying to work out the best way of going about this but i was a bit shocked to find that both companies use a pretty much identical editor (as can be seen in the attachments). This led me to think are they are using a flash component that can be bought by anyone or did they just both happen to build the flash code themselves? Does anyone know if this editor can be bought as a component, if not how hard to you think it would be to build the code from scratch? Any help appreciated would be great. Many thanks John [attachment deleted by admin]
  9. Hey I have an simple form set up in my 'main.php' page with one field causing me problems which is below: <input id="exact" class="exact" name="exact" size="10"/><input type="submit" name="send" value="ApplyExact" /> So the once the user enters their input in the 'exact' field they submit the form. I have a 'require_once("validate.php"); set up that links a php file which has the following function to validate the input to check if it matches one of the exact terms in either of the 3 arrays: function validateExact($exact){ if(strlen($exact) < 10) return false; if(strlen($exact) >10) return false; $colour_one = array('red','orange','yellow''); $colour_two = array('pink','purple'); $colour_three = array('blue','grey','white'); if ( in_array($exact, $colour_one) ) return true; if ( in_array($exact, $colour_two) ) return true; if ( in_array($exact, $colour_three) ) return true; else return false; } Now back in my 'main.php' page once the submit button has been pressed the user gets taken to the 'ApplyExact' case which has the following code: $_SESSION['exact'] = $_POST['exact']; if( isset($_POST['exact']) && (!validateExact($_POST['exact']))) { echo ('<tr><td><td>The Colour is Invalid</td></tr><tr><tr><td>Colour<input id="exact" class="exact" name="exact" size="10"/><input type="submit" name="send" value="ApplyExact" /></td></tr>'); } else { echo ('<tr><td>Your Colour is '.$_SESSION['exact'].' and is valued at '.$type.'</td></tr>'); } Now this all works fine and i get the users colour choice echoed back if it is stored in one of the arrays but the problem i have is that i cannot get the variable of '$type' to be displayed. I need to set a variable of 'type' - which value depends on what colour array the user selected. So for example if they enter any of red, orange or yellow from the array '$colour_one' then $type = .30. If they enter pink or purple from the array '$colour_two' then $type = .50 and so on... I have tried numerous different attempts at getting this working including the below which i thought should work but isn't. Are the 2 examples below completely wrong and i need another way around this or am i missing something? ...if ( in_array($exact, $colour_one) ) return true; $type = .30; if ( in_array($exact, $colour_two) ) return true; $type = .50; if ( in_array($exact, $colour_three) ) return true; $type = .60; else return false; } or by: ...if ( in_array($exact, $colour_one) ) $type = .30; $true = true && $type; return $true; if ( in_array($exact, $colour_two) ) $type = .50; $true = true && $type; return $true; if ( in_array($exact, $colour_three) ) $type = .60; $true = true && $type; return $true; else return false; } If anyone can help with this? I have only posted the sections of the code that relate to my problem and question as the whole script for 'main.php' is about 1200 lines long with 'validate.php' 140 lines so tried to make it a bit clearer and easier. Many thanks Jon
  10. An array is ideal for what i am doing thank you, simple really, shows that i am still a newbie with PHP! Thank you again!
  11. Hey I am struggling in trying to find a solution for the above problem. I have a simple html form and have some php code set up to validate the user input. Below is an example of how i am validating one particular field: function validateField1($field1){ //if it's NOT valid if(strlen($field1) < 1) return false; if(!preg_match('/^[A-Za-z0-9 ]+$/', $field1)) return false; //if it's valid else return true; So for that field if the user fails to enter anything or if they include anything other than Lower/Uppercase letters, numbers and a space then the script returns false and brings up the error. Now i am trying to set up some fields where by the user must match their input with an exact string that i will set for it to correctly validate otherwise it will flag an error. So for example on 'field 2' - the user must enter the input of 'red' or 'blue' or 'green' or 'pink'. Anything other than either 1 of these will not be passed. Now i know instantly from that it would seem i should just use the 'select name' and 'option' values for my html to just have those 4 options in a drop down list to select but it needs to be a typed user input not selected from a list. Am i able to add exact terms into the above validation example or do i need to use a different technique? I have a feeling that it might be best to use MySql with this in the form of a database but i unfortunately have no knowledge of this language at present... Is anyone able to help me out on this one? Many thanks Jon
  12. Is there a logical way to solve this then or is the entire code not possible to do?
  13. Hey I cannot get my php validation code to run without errors. I get the following error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in... I have 'validate.php' which sets the validation functions for each and i call this in 'require_once' at the start of my main php page. I have a switch statement that when 'formchoiceone' is chosen it echos the form and the validation. I have tested this code in a standard php file (one that does not output the form and validation in an echo) and it all works fine but having it inside the echo is producing errors. Code is below: validate.php <?php function validateInputOne($one){ //if it's NOT valid if(ereg('[^A-Za-z]', $one)) return false; //if it's valid else return true; } function validateInputTwo($two){ //if it's NOT valid if(ereg('[^0-9]', $two)) return false; //if it's valid else return true; } ?> main php page <?php session_start(); require_once("validate.php"); switch ($choice) { case 'formchoiceone': echo ' <div id=form> <form name="formone" method="post" action=""> if( isset($_POST['send']) && (!validateInputOne($_POST['one']) || !validateInputTwo($_POST['two]) ) ): <div id="error"> if(!validateInputOne($_POST['one'])): <p class="cform">[Please enter Letters Only]</p> endif if(!validateInputTwo($_POST['two'])): <p class="cform">[Please enter Numbers Only]</p> endif </div> elseif(isset($_POST['send'])): <div id="error" class="valid"> </div> endif <p class="cform">Name<input id="one" name="one" type="text"/></p> <p class="cform">Age<input id="two" name="two" type="text"/></p> <input id="send" name="send" class="submitbutton" type="submit" value="Send"></input> </form> </div>'; break; ?> Any ideas on this? Had me stuck for days now... Thanks Jon
  14. Hey I have tested it on safari and firefox, both having cookies enabled and it still doesn't work...
  15. Hey I cannot seem to recall my session variables throughout my site and i cannot see where i am going wrong. I have variables in my flash file which i have posted into my 'info.php' all working fine, i declare the post variables in 'info.php' with the following: [b]$num[/b] = $_POST['number']; [b]$choice[/b] = $_POST['choice']; [b]$colour[/b] = $_POST['colour']; These variables then get called in a simple form that is echo'd as below: echo '<div id="info"> <form name="form" method="post" action=""> <table width="450" border="0" cellspacing="1" cellpadding="3"> <tr><td width="65%"><strong>Number</strong></td> <td width="65%"><strong>Choice</strong></td> <td width="20%"><strong>Colour</strong></td> <td width="15%"><strong>Quantity</strong></td></tr> <tr><td>[b]'.$num.'[/b]</td><td>[b]'.$choice.'[/b]</td><td><input type="text" name="colour" value="[b]'.$colour.'[/b]"readonly></td> <td><input type="text" name="qty1" size="5" value="1"> </td></tr> <tr valign="bottom"><td><br>Paying with: <br> <input type="radio" name="x" value="CashPayment" checked="checked">Cash<br> <input type="radio" name="x" value="CardPayment">Card</td> <input type="submit" name="Submit" value="Submit"></td></tr> </table> </form>'; I then set the post variables to session variables with the following: $num = $_POST['number']; $choice = $_POST['choice']; $colour = $_POST['colour']; [b]$_SESSION['num'][/b] = $_POST['number']; [b]$_SESSION['choice'][/b] = $_POST['choice']; [b]$_SESSION['colour'][/b] = $_POST['colour']; So the form has the session variables stated as in: echo '<div id="info"> <form name="form" method="post" action=""> <table width="450" border="0" cellspacing="1" cellpadding="3"> <tr><td width="65%"><strong>Number</strong></td> <td width="65%"><strong>Choice</strong></td> <td width="20%"><strong>Colour</strong></td> <td width="15%"><strong>Quantity</strong></td></tr> <tr><td>[b]'. $_SESSION['num'].'[/b]</td><td>[b]'. $_SESSION['choice'].'[/b]</td><td><input type="text" name="colour" value="[b]'. $_SESSION['colour'].'[/b]"readonly></td> <td><input type="text" name="qty1" size="5" value="1"> </td></tr> <tr valign="bottom"><td><br>Paying with: <br> <input type="radio" name="x" value="CashPayment" checked="checked">Cash<br> <input type="radio" name="x" value="CardPayment">Card</td> <input type="submit" name="Submit" value="Submit"></td></tr> </table> </form>'; I have <?php session_start(); At the top of every php page. Can anyone help me with what i am doing wrong? The variables display when you first go to 'info.php' but as soon as you navigate away and then back the fields are empty. Any ideas? Many thanks Jon
  16. Hey I am struggling with sending some variables to a php page from my flash movie. On the last frame of my flash movie i have a button which navigates the user onto a new php page where i want to display the variables in. The code i currently have is : AS3 - // set variables as a string containing the dynamic textfield. var Introduction:String = (introduction_txt.text); // var Choices:String = (summary_txt.text); // //// Send Variable to php. var requestVar:URLRequest = new URLRequest ("http://www.photoincanvas.co.uk/shopping-basket.php"); request.method = URLRequestMethod.POST; var variables:URLVariables = new URLVariables(); variables.Intro = "Introduction"; variables.Choices = "Choices"; request.data = variables; var loaderVar:URLLoader = new URLLoader (request); loaderVar.addEventListener(Event.COMPLETE, onComplete); loaderVar.dataFormat = URLLoaderDataFormat.VARIABLES; loaderVar.load(request); function onComplete (event:Event):void{ status_txt.text = event.target.data; } PHP code on new page - <?php $intro = $_POST['Intro']; $choice = $_POST['Choices']; echo "Intro=" . $intro; ?> The echo in the php page comes up as Intro=, I need to echo the variable of $intro which contains the dynamic text in 'introduction_txt.text' in flash. If anyone can help me out on this one?? Many Thanks Jon
  17. Got it working in the end thanks to 'moagrius' on another forum for helping me! SOlved by: first, you need to give Flash the new file name. You can use a standard querystring or Flash vars, and php to echo it out: PHP Code: <param name="movie" value="Test_Editor.swf?filename=<?php echo $newname; ?>" /> ... <object type="application/x-shockwave-flash" data="Test_Editor.swf?filename=<?php echo $newname; ?>" width="964" height="510"> as you can see, we set a variable named "filename" to the $newname php variable. now, it'll be availabe in flash in the loaderInfo.parameters object, which will now have a property named "filename" that will be the path from $newname: PHP Code: var imageFilePath:String = root.loaderInfo.parameters.filename; then load it into flash using a Loader object: PHP Code: var loader:Loader = new Loader(); var request:URLRequest = new URLRequest(imageFilePath); loader.load(request); addChild(loader);
  18. Hey Thanks for the reply! I have just started looking into zendamf and amfphp but still a little confused on how to go about linking flash and the php together. I have started another thread which includes the ongoing flash file and links to the temporary site if that helps (gives you a better idea rather than the list of what i wanted to do in thsi thread!) Link is below. http://www.phpfreaks.com/forums/index.php/topic,282379.msg1338649.html#msg1338649 I have got the flash photo manipulation part working, i now just to need to get the uploaded file into the emptymovie clip in my swf. I have a working php and html form upload script that saves to th server in the 'images' folder but i need to trigger flash to load into the movie once upload is complete. Any further help much appreciated! Thanks Jon
  19. Hey I am in the middle of trying to create an swf that allows the user to upload an image into the flash file and manipulate it in several ways using actionscript 3 and flash cs4. (ideally if possible keeping the flash player needed at 9 or lower) A link to the ongoing example can be found here - http://www.photoincanvas.co.uk/test/test-editor.html I have solved most of the photo editing side, but am having trouble uploading any photo into the flash file. I have looked into the 'getfile reference' class and also the 'oncompletedata' but havent got it working. Can anyone help? I need the user to click on the upload button on frame one which will upload the file to the server and display it on frame 2 in the empty_mc (instance of myObject) Currently i have a random jpeg image in its place. Originally i intended to use an html form and php upload script to do all the uploading then send the url link into flash but again cannot come up with a way for this. If this is the better way i have a working php upload on the below link > http://www.photoincanvas.co.uk/test/ This successfully uploads my image onto the server in the 'images' folder but how do i get this into my swf? The html and php code for this is > HTML CODE - <form name="newad" method="post" enctype="multipart/form-data" action="upload.php"> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> PHP UPLOAD CODE - <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","7000"); //define a minim size for the uploaded images in Kb define ("MIN_SIZE","100"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "tif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } if ($size < MIN_SIZE*1024) { echo '<h1>You have not met the minimum size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="images/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully!</h1>"; } ?> Zip file containing the fla file etc is attached. Any help much appreciated, i have spent the last 3-4 days trying out different tutorials, source codes and my own limited knowledge!! with no luck Thanks Jon [attachment deleted by admin]
  20. Hey Am looking at how to get an image that i have uploaded onto a web server into my flash movie file but am struggling with the actionscript needed to call the file into flash. Is there an actionscript class that can call an image that has just been uploaded onto the server and place it into a movieclip? Struggling to find a code as each image will have a unique number. Is there a code that can link into a php session that starts as the users uploads the image? I have found several tutorials for loading data/text into flash using either the 'filereference class' or the 'moviecliploader' but these seem to need a string or a url for the data fro flash to get. Another option is to have the upload script in flash itself but i do not want this either. I have a test php upload script that is currently on (with php code posted below) http://www.photoincanvas.co.uk/test/ <?php //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","7000"); //define a minim size for the uploaded images in Kb define ("MIN_SIZE","100"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "tif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } if ($size < MIN_SIZE*1024) { echo '<h1>You have not met the minimum size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="images/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully!</h1>"; } ?> Have serached google and forums for the last 3 days with no luck so any help please! Many thanks Jon
  21. Hey Hope i have put this in the right topic, apologies if i haven't! I had posted this in the PHP section but think it may be more relevant in Flash as have'nt had any replies yet... I have been asked to create a photo canvas website that allows users to upload an image, then apply several effects such as re-sizing/cropping/desaturate, then viewing the updated image on a generic wall and going to check out to buy the canvas. I am pretty new to web developing/designing, i am confident with html,css and actionscript to an extent, but have only used small parts of php before. My biggest worry is how to go between html > php >flash >back to html again. From what i understand i need to create the following functions: 1. Create a general html website which will store the upload form and flash photo editor swf on, when the user first access's the site i start the php session... 2. The user then uploads there image to the server using a simple php upload form which will store the file and create a unique named file also on the server... 3. The flash editor swf will then load up on the html page. Inside the actionscript of the swf i will tell flash to continue with the php session by calling it again and call users image on the server with the 'file reference' command. The editing functions such as cropping, canvas size will all have variables to mark what the user has chosen and these varaibles will get ent back to the html page using php to keep track of them for the checkout process... 4. Once the editing has finished the user will click 'finish' in the swf taking them to the php shopping basket/checkout which will call the variables sent in flash to determine final cost depending on what effects chosen. Is the above correct and more importantly is it possible? The main part i am struggling to get my head around is editing in flash (say changing the uploaded image to 20 x 26) and then saving this back to the server and sending the new settings back into the html/php page. Is this all possible without using database and tables such as MySql? Sorry for the long post, just wanted to try and explain how i thought it might work nd not just ask how to do it straight away! Any comments what so ever much appreciated! Many thanks Jon
  22. Hey Hope i have put this in the right topic, apologies if i haven't! I have been asked to create a photo canvas website that allows users to upload an image, then apply several effects such as re-sizing/cropping/desaturate, then viewing the updated image on a generic wall and going to check out to buy the canvas. Similar site that has the features i want is this : http://www.portrayit.co.uk/ I am pretty new to web developing/designing, i am confident with html,css and actionscript to an extent, but have only used small parts of php before. My biggest worry is how to go between html > php >flash >back to html again. From what i understand i need to create the following functions: 1. Create a general html website which will store the upload form and flash photo editor swf on, when the user first access's the site i start the php session... 2. The user then uploads there image to the server using a simple php upload form which will store the file and create a unique named file also on the server... 3. The flash editor swf will then load up on the html page. Inside the actionscript of the swf i will tell flash to continue with the php session by calling it again and call users image on the server with the 'file reference' command. The editing functions such as cropping, canvas size will all have variables to mark what the user has chosen and these varaibles will get ent back to the html page using php to keep track of them for the checkout process... 4. Once the editing has finished the user will click 'finish' in the swf taking them to the php shopping basket/checkout which will call the variables sent in flash to determine final cost depending on what effects chosen. Is the above correct and more importantly is it possible? The main part i am struggling to get my head around is editing in flash (say changing the uploaded image to 20 x 26) and then saving this back to the server and sending the new settings back into the html/php page. Is this all possible without using database and tables such as MySql? Sorry for the long post, just wanted to try and explain how i thought it might work nd not just ask how to do it straight away! Any comments what so ever much appreciated! Many thanks Jon
×
×
  • 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.