User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,818 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,801 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 219 | Replies: 0
Reply
Join Date: Jul 2006
Posts: 158
Reputation: tefflox is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
tefflox's Avatar
tefflox tefflox is offline Offline
Junior Poster

Please help debug my code

  #1  
May 12th, 2008
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++;		
    }
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC