tefflox 2 Junior Poster

Hi, Dreamhost has demonstrated image magick utilities can work from a web page.

Please glance through my code, and help me find how to get it right.

As it is, available at tefflox.net/clients/superiorminitrucks/admin (if you want to see the errors)

the photos are uploaded just fine, but they are not resized.

tefflox.net/clients/superiorminitrucks/admin/dhtest.php also works. i am trying to get its functionality to work in the ~/upload.php script, accessible from the foremost address.

thank you. I hope to deliver this package to the client by wednesday.

here is the pertinent segment of the code ----


The counter variable, $img, is declared first thing in the php code.

// now we can loop through $files, and feed each element to the class
    

	$location = '/usr/bin/mogrify';
	
	foreach ($files as $file) {
    
        // we instanciate the class for each element of $file
        $handle = new Upload($file);
        
        // then we check if the file has been uploaded properly
        // in its *temporary* location in the server (often, it is /tmp)
        if ($handle->uploaded) {

            // now, we start the upload 'process'. That is, to copy the uploaded file
            // from its temporary location to the wanted location
            // It could be something like $handle->Process('/home/www/my_uploads/');
			
			/**********************
						mogrify images
					***************************/
			
			
			
			if($img == 0) {
				$command  = "/usr/bin/mogrify -resize 600x450 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }
				
			else if ($img == 1) {
				$command  = "/usr/bin/mogrify -resize 600x450 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }			

			else if ($img == 2) {
				$command  = "/usr/bin/mogrify -resize 600x450 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }			

			else if ($img == 3) {
				$command  = "/usr/bin/mogrify -resize 600x450 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }			

			else if ($img == 4) {
				$command  = "/usr/bin/mogrify -resize 300x225 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }
			
			else if ($img == 5) {
				$command  = "/usr/bin/mogrify -resize 100x75 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }			
			
			else if ($img == 6) {
				$command  = "/usr/bin/mogrify -resize 100x75 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }			
		
			else if ($img == 7) {
				$command  = "/usr/bin/mogrify -resize 100x75 " . $file[$img];
		       	exec ($command);
				$handle->Process("../inventory/trucks/"); }			
		




            // we check if everything went OK
            if ($handle->processed) {
                // everything was fine !
                echo '<fieldset>';
                echo '  <legend>file uploaded with success</legend>';
	
				
                echo '  <img alt="" src="../inventory/trucks/' . $handle->file_dst_name . '" />';
                echo '</fieldset>';
            } else {
                // one error occured
                echo '<fieldset>';
                echo '  <legend>file not uploaded to the wanted location</legend>';
                echo '  Error: ' . $handle->error . '';
                echo '</fieldset>';
            }
            
        } else {
            // if we're here, the upload file failed for some reasons
            // i.e. the server didn't receive the file
            echo '<fieldset>';
            echo '  <legend>file not uploaded on the server</legend>';
            echo '  Error: ' . $handle->error . '';
            echo '</fieldset>';
        }
	    	$img++;		
    }