0

The if else state is as follows:

 if ( isset( $_POST['submit'] ) ) {
      $extension = end(explode(".", $_FILES["file"]["name"]));
      if ((($_FILES["file"]["type"] == "image/gif")
                      || ($_FILES["file"]["type"] == "image/jpeg")
                      || ($_FILES["file"]["type"] == "image/png")
                      || ($_FILES["file"]["type"] == "image/pjpeg"))
                      && ($_FILES["file"]["size"] < 60000)
                      && in_array($extension, $allowedExts)){
         if ($_FILES["file"]["error"] > 0)
         {
               // Do something
         } else{
               if (file_exists(EXAMPLE_IMAGES_PATH . $_FILES["file"]["name"])) {
                     // Do something
               } else{
                  // Apply resize then -
                  move_uploaded_file($_FILES["file"]["tmp_name"],
                        EXAMPLE_IMAGES_PATH . $_FILES["file"]["name"]);
                  // Do something else
               }
         }
   }
  else{
     // Do something else
  }

}

On move_uploaded_file I'd like to have it resized to

  $uploadedfile = $_FILES['file']['tmp_name'];
  $imgW = 290;   // Width of img to be uploaded
  $imgH = 290;   // Height of img to be uploaded
  imagecreatetruecolor($imgW,$imgH);

I'm not sure as to how to implement resize to the image before upload. Thanks in advance to all who give assistance.

janenz00
  • 3,315
  • 5
  • 28
  • 37
Tony
  • 315
  • 1
  • 4
  • 13
  • If you are executing `move_uploaded_file`, then the file essentially has already been uploaded to the servers `temp` location. There shouldn't be much of a difference when you do the resize. I'd recommend doing it after `move_uploaded_file` because then you'll be sure the entire upload process is completed. – Lix Oct 14 '12 at 00:34
  • @Lix - why can't I do it before the move_uploaded_file executes? And how can I implement it to do it after move_uploaded_file? – Tony Oct 14 '12 at 00:39
  • there is no reason you can't. The more appropriate question would be why do you want to do it this way? For me at least, only after I execute `move_uploaded_file` am I confident that the file was successfully uploaded (to the right place). Before that, all uploaded files get dumped in the same place. – Lix Oct 14 '12 at 00:41
  • But with the other portions of my if else statemant the move_uploaded_ file won't occur. Whether the file already exists, allowed ext's, size, etc. – Tony Oct 14 '12 at 00:49
  • @janenz - Why would you edit the markup in my post without any other contributions? I thought the original markup was clean and more eligible anyways? I'll conclude with "whatever" on that. – Tony Oct 14 '12 at 01:15
  • @Lix your contributions is understandable but is somewhat really not helpful. I'd like to think that if your going to comment on this site or if a person edits a post on this site that users should be able to get something out of it. – Tony Oct 14 '12 at 01:17
  • We are regular [so] users and programmers just like you. I'm sorry that you feel my comments are not helpful, and with your current attitude I'm sorry I commented at all. In the future, if you plan to continue using the site, I recommend that you try be more open to suggestions that people are giving you free of charge and from their own spare time. Good luck with your project. – Lix Oct 14 '12 at 01:26
  • @Lix I wasn't being disrespectful I just figured that me and or other users who may visit this question would appreciate less vague comments and have more clarity and assistance. Also why update a post for no reason. Did they find something wrong with my original post? If so wouldn't a comment from the person who made the edit and why they made the edit be helpful? I do appreciate all who attempt to help so please don't assume that I'm unappreciative. – Tony Oct 14 '12 at 01:45

1 Answers1

1

I recommend to use: http://phpthumb.gxdlabs.com/