Results 1 to 3 of 3

Thread: PHP and Javascript

  1. #1
    Join Date
    Nov 2010
    Posts
    115
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default PHP and Javascript

    Hi All,

    can anyone help me,.The below is my code

    PHP Code:
    $size getimagesize("uploads/image.jpeg");
    $message "$size[mime]";

    if (
    $message!=image/jpeg)
    {
    echo
    "this image format is not supported"; (here i need it to be displayed as javascript alertis it possible)

    and the other thing is, when i used getimagesize()
    PHP Code:
    $size=getimagesize("uploads/image.jpeg");
    print_r($size
    Array ( [0] => 2560 [1] => 1600 [2] => 2 [3] => width="2560" height="1600" [bits] => 8 [channels] => 3 [mime] => image/jpeg )
    Actually the image is around 60 kb. but it is not showing any image size in the above.
    Last edited by jscheuer1; 12-25-2010 at 03:30 PM. Reason: format post

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    1. The code you show can probably be made as a javascript alert like so:

      Code:
      $size = getimagesize("uploads/image.jpeg"); 
      $message = "$size[mime]"; 
      
      if ($message!=image/jpeg) 
      { 
      ?><script type="text/javascript">
      alert("this image format is not supported");
      </script><noscript>
      this image format is not supported
      </noscript>
      <?php
      }
      I say probably because I can't see everything else or the served source code. But if it was echoing, it should now alert. Except if javascript is disabled, in which case it will still write the information to the page.


    2. The PHP function getimagesize() is for dimensions and a few other things, not bytes. If you want bytes, use the PHP filesize() function.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    hemi519 (12-25-2010)

  4. #3
    Join Date
    Nov 2010
    Posts
    115
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Default

    thnku

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •