Jump to content

Image Upload


brown2005

Recommended Posts

if($_SERVER['REQUEST_METHOD'] == "POST")

{

 

$uploaddir = "http://www.links-bid.com/include/adverts/";

 

    $pext = getFileExtension($imgfile_name);

   

    $pext = strtolower($pext);

   

    if (($pext != "jpg") && ($pext != "jpeg") && ($pext != "gif"))

    {

       

print "<h1>ERROR</h1>Image Extension Unknown.<br>";

        print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>";

        print "The file you uploaded had the following extension: $pext</p>\n";

 

        unlink($imgfile);

       

        exit();

   

}

 

    $imgsize = GetImageSize($imgfile);

 

    if (($imgsize[0] > 250) || ($imgsize[1] > 200))

    {

 

        $tmpimg = tempnam("/tmp", "MKUP");

 

        system("djpeg $imgfile >$tmpimg");

 

        system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile");

 

        unlink($tmpimg);

 

    }

 

    $final_filename = str_replace(" ", "_", $imgfile_name);

 

    $newfile = $uploaddir . "/$final_filename";

 

    if (is_uploaded_file($imgfile))

    {

     

      if (!copy($imgfile,"$newfile"))

      {

 

          print "Error Uploading File.";

         

          exit();

     

  }

   

}

 

    unlink($imgfile);

 

    print("<img src=\"$final_filename\">");

 

}

 

where would I put that in this script though? please

Link to comment
https://forums.phpfreaks.com/topic/40336-image-upload/#findComment-195171
Share on other sites

$new_name = $name1.'_'.$name2.'.'.$pext;

 

Note the .'.'. looks confusing. A dot appends text to a string. So we are appending the string '.' with the extension 'jpg' to get '.jpg' and this is appended to the file name:

 

'/usr/bin/kittens/hello_world.jpg'

 

monk.e.boy

 

 

Link to comment
https://forums.phpfreaks.com/topic/40336-image-upload/#findComment-195213
Share on other sites

$uploaddir = "adverts";

 

    $pext = getFileExtension($imgfile_name);

   

    $pext = strtolower($pext);

   

    if(($pext != "jpg") && ($pext != "jpeg") && ($pext != "gif"))

    {

       

print "<h1>ERROR</h1>Image Extension Unknown.<br>";

        print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>";

        print "The file you uploaded had the following extension: $pext</p>\n";

 

        unlink($imgfile);

       

        exit();

   

}

 

    $final_filename = $amount.'_'.$place.'.'.$pext;

 

    $newfile = $uploaddir . "/$final_filename";

 

    if(is_uploaded_file($imgfile))

    {

     

      if (!copy($imgfile,"$newfile"))

      {

 

          print "Error Uploading File.";

         

          exit();

     

  }

   

}

 

    unlink($imgfile);

 

}

 

 

i have that but it is not putting the image in the folder, any ideas?

Link to comment
https://forums.phpfreaks.com/topic/40336-image-upload/#findComment-195221
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.