Trying to upload a jpeg image and make 3 different sized copies
<p>Hey guys,
I am allowing users of my site to upload an image for the site.
The idea is that when they choose a file to upload, 3 copies will be made. Each of them has differing dimensions for differing purposes around the site.</p>

<p>I wrote a function to handle the upload and then 3 seperate functions called from within the main function to do each resize.</p>

<p>At present, only the first resize is working.
I have tested all three functions of code and they all work individually but not collectively.</p>

<p>The main function:</p>

<pre><code>function uploadImage($image){
    global $form;

    //define some variables
    $i = $_SESSION['id'];
    $source = $image['tmp_name'];
    $source2 = $image['name'];
    $file = explode('.', $source2);
    $ext = strtolower(end($file));

    //profile image variables
    $profileimage = $i . '.jpg';
    $profiletarget = "images/users/".$profileimage;

    //forum/ discussion image variables
    $forumimage = $i . 'a.jpg';
    $forumtarget = "images/users/".$forumimage;

    //favourite user image variables
    $favimage = $i . 'b.jpg';
    $favtarget = "images/users/".$favimage;

    $field = "image";
    //check user has selected an image
    if(!$image){
        $form-&gt;setError($field, "* Image not selected");
    }
    //check if image is a jpeg
    else if ($ext != 'jpg' &amp;&amp; $ext != 'jpeg'){
        $form-&gt;setError($field, "* The upload must be a jpeg, yours is: $ext");
    }

    if($form-&gt;num_errors &gt; 0){
        return 1;
    }
    else if ($form-&gt;num_errors == 0){
        //upload a profile image, forum image, fav image
        $this-&gt;uploadProfileImage($source, $profiletarget, $profileimage);
        $this-&gt;uploadForumImage($source, $forumtarget, $forumimage);
        $this-&gt;uploadFavImage($source, $favtarget, $favimage);
        return 0;
    }
    else{
        return 2;
    }

}
</code></pre>

<p>As you can see, towards the bottom of the script, I call three functions.
Whichever function is first out of the three seems to work, but the following two won't. I have juggled the functions around so all 3 have been first at various points of testing and all three worked perfectly but only when first.</p>

<p>Is there any specific reason anyone can see as to why this is happening?</p>

<p>As previously mentioned, I have tested each function individually so the file is being passed through no problem and all validation is being achieve correctly.</p>

<p>Thanks for reading.</p>
