Jump to content

Leao

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Leao's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Oops, I didn't realise this. Thanks Leao
  2. Hi, I want to send the following variable using the $_GET function: www.example.com/index.php?id=https://twitter.com/intent/tweet?url=http%3A//youtu.be/gvckPiuN9ug&text=The%20first%20kinetic%20typography%20film%20%5B1988%5D%20Oliver%20Harrison%20%5Bpart%5D.:&via=YouTube&related=YouTube,YouTubeTrends,YTCreators The page that receives this variable then echoes it out in a refresh meta tag to redirect to a new page: <meta http-equiv="refresh" content="0; url= <?php echo $_GET[‘id’]; ?>" /> The problem is that $_GET in the above example contains multiple variables after the initial $id variable, meaning that rather than redirecting to the above URL in its entirety, it instead redirects to: www.twitter.com/intent/tweet?url=http%3A//youtu.be/gvckPiuN9ug Is there a simple way around this? Many thanks, Leao
  3. Hi, How do I do multiple if statements? I'm sending some variables from an HTML form to the PHP script below. The script is supposed to check if the 3 variables 'apples', 'pears' and 'bananas' have been received by the form and echo "All the elements are present." If all the elements aren't present the script should echo "ERROR!" Cheers, Leao [code=php:0]<?php if (isset($_POST['apples'])) if (isset($_POST['pears'])) if (isset($_POST['bananas'])) {echo "All the elements are present.";} else {echo "ERROR!";} ?>[/code]
  4. Thanks, I tried this and... it worked! [code=php:0]if ($ImportMimeType != 2) { echo "Sorry your file needs to be a JPEG image."; $ok=0; } [/code]
  5. Hi, I need a PHP script that excludes images sent from a form that aren't JPEGs. I originally tried this PHP script: [code=php:0] <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']); $ok=1; if ($uploaded_type != 'image/jpeg') { { echo "Sorry your file needs to be a JPEG image."; $ok=0; } if ($ok==0) { echo "Sorry your file was not uploaded"; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], 'images/title.jpg')) { echo "Your image has been uploaded."; } else { echo "Sorry, there was a problem uploading your file."; } ?> [/code] This script worked perfectly on most computers, but on those that hide file extensions it rejected even valid JPEG images. I tried the getimagesize() method below too as an alternative means of rejecting non JPEG files. It doesn't work either, can you help? Thanks – Leao [code=php:0] <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']); $ok=1; list($ImportWidth,$ImportHeight,$ImageMimeType) = getimagesize($_FILES['uploaded']['tmp_name']) ; if ($ImportMimeType != 'image/jpeg') { echo "Sorry your file needs to be a JPEG image."; $ok=0; } if ($ok==0) { echo "Sorry your file was not uploaded"; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], 'images/title.jpg')) { echo "Your image has been uploaded."; } else { echo "Sorry, there was a problem uploading your file."; } ?> [/code]
  6. Thank you very much : ) It works great!
  7. Hi, thanks. When I copied and pasted the code to PHP Freaks I changed the variables to suit those you had used but forgot to change one of them. It doesn't work even with the proper variables. Any ideas?
  8. I don't really want to resize images, just to check if they're the correct dimensions and then ask the user to reupload the images at the right dimensions if they're not. I tried the getimagesize() function but it didn't work. Even if the image was exactly 500 pixels in width I still got the 'Your file is not the correct width...' error message and also: [quote]PHP Warning: getimagesize(image.jpg): failed to open stream: No such file or directory in C:\hshome\mydomain\mydomain.org\test\upload.php on line 7[/quote] The php I tried was: [code=php:0]list($ImportWidth,$ImportHeight,$ImageMimeType) = getimagesize($_FILES['uploaded']['name']) ; if ($ImportWidth != 500) { echo "Your file is not the correct width of 500 pixels.<br>"; $ok=0; }[/code] I probably entered it incorrectly. thanx leo
  9. The file is renamed as it's uploaded now, thanks! I'm new to PHP so I'm afraid your code for checking the image's pixel dimensions is perplexing. Is there a way of checking an image's pixel dimensions in a similar way to how I check the image's file size below, using getimagesize() for example? [code=php:0] if (!($uploaded_type=="image/jpeg")) { echo "You may only upload JPEG files.<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded"; } [/code] Cheers, Leao
  10. Hi, I'm using a form to upload a jpeg image to my server via PHP (see code). I'd like to rename the jpeg as title.jpg before uploading it to the server and also I'd like to reject the image if it isn't exactly 500x375 pixels. I've searched the net but can only find a few tutorials about renaming files with random file names in order to avoid overwriting old ones but I actually want to overwrite old image files so I want to rename files to a specific name rather than to a random one. I can't find much either about checking an image's pixel dimensions either. Thanks – leao [code]<?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']); $ok=1; if ($uploaded_size > 70000) { echo "Your file is too large.<br>"; $ok=0; } if (!($uploaded_type=="image/jpeg")) { echo "You may only upload JPEG files.<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded"; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?>[/code]
×
×
  • 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.