Jump to content

Grimloch

Members
  • Posts

    67
  • Joined

  • Last visited

    Never

About Grimloch

  • Birthday 11/03/1949

Contact Methods

  • Website URL
    http://www.whisperwillow.com

Profile Information

  • Gender
    Male
  • Location
    La Porte, Texas USA

Grimloch's Achievements

Member

Member (2/5)

0

Reputation

  1. Well, I don't really understand why but it's obvious to me now that I can no longer expect any help from anyone on this forum system. Thats too bad because I found it to be a valuable resource and may still read posts from time to time. But you won't be bothered by my requests for help anymore as it has become pointless. Thanks to everyone on here who DID help me; I appreciate it. So long.
  2. I am totally absolutely bewildered. Why is it that I can't seem to get any help here with my problem? No suggestions; no comments; no NOTHING! Is this problem too tough for anyone here? Is thing thing I am trying to accomplish an undo-able thing in PHP/MySQL? Since I've made some rather hasty and regrettable comments on previous posts, is it that no one wants to bother with me? Exactly what is the problem here? If no one can help PLEASE at least point me to where I CAN get some help.
  3. ...I am getting closer and closer. After much experimentation I determined that my $img_name and $img_ext 'strtolower' functions were not right and it was never separating the filenames into name,extension. Here is my code now: // ad image upload while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $img_name = strtolower(substr($imagename, 0, strrpos($imagename, "."))); $img_ext = strtolower(strrchr($imagename,".")); $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; $thumbs = INFUSIONS.'classified_ads_panel/images/ads/thum/'; $img_file = image_exists($target, $img_name.$img_ext); move_uploaded_file($source, $target); $imagefile = @getimagesize($img_file); $thb = image_exists($target, $img_name."_t1".$img_ext); createthumbnail($imagefile[2], $thumbs.$img_file, $thumbs.$thb, $settings['thumb_w'], $settings['thumb_h']); } } // end ad image upload And here is an image of my ftp dir after upload. The thumb function is now writing the correct filename but the files are still empty. Please, if anyone can see what I am doing wrong here I would be most greatful! Then I must solve the db update coding. Thanks in advance.
  4. Hello folks I'm back again. I'm right on the verge of solving the middle third of my 3 part equation for uploading multiple images to a classified ads script in PHP-Fusion7 CMS. The 3 part equation is: 1) Upload and save multiple images - works! 2) Generate and save thumbs for them - almost works. 3) Update db with image/thumb info - not tackled yet, don't know how. Part 2: Here is the code I have in place now that successfully uploads and saves multiple images. function Add($cat, $title, $description, $url, $weeks, $owner, $owner_id) { global $adstext, $locale, $userdata, $settings, $db_prefix; require_once INCLUDES."photo_functions_include.php"; if(isset($_POST[save_ad])) { $postdate = time(); $expiredate = $postdate + (3600 * 24 * $weeks); $url = explode("http://", $url); if ($url[1]=="") { $myurl = ""; } else { $myurl ="$url[1]"; } // Check if Category exist if ($cat=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0041']."<br />"; exit(); } // Check if Title exist if ($title=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0042']."<br />"; exit(); } // Check if ads text exist if ($description=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0043']."<br />"; exit(); } // Check ads text length if (strlen($description) > $adstext) { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0044'].": $adstext characters.<br />"; exit(); } $title = addslashes($title); $description = addslashes($description); // ad image upload while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $img_pic = $_FILES['imagename']; $img_name = strtolower(substr($img_pic['name'][$key], 0, strrpos($img_pic['name'][$key], "."))); $img_ext = strtolower(strrchr($img_pic['name'][$key],".")); $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; $thumbs = INFUSIONS.'classified_ads_panel/images/ads/thum/'.$imagename; $img_file = image_exists($target, $img_name.$img_ext); move_uploaded_file($source, $target); $imagefile = @getimagesize($target.$img_file); $thb = image_exists($target, $img_name."_t1".$img_ext); createthumbnail($imagefile[2], $thumbs.$img_file, $thumbs.$thb, $settings['thumb_w'], $settings['thumb_h']); } } // end ad image upload These are images of my ftp directory after upload: Complete dir is: infusions/classified_ads_panel/images/ads/thum/ images/ads are main images and ads/thum are thumbnails As you can see its writing the thumb filenames but incorrectly and the files are empty. I've racked my brain trying to figure out what I have wrong in the code and just can't seem to get my head around it. Any help appreciated.
  5. I need to close this thread as solved because the actual problem (multi-image upload), is now working although this is only 1/3 of the entire equation I need to solve. I will either start a new thread or seek other resources for help. Thanks to all who have helped me here.
  6. OK this is wrong; the problem was I was uploading images from the same few. I guess I just lost track. The code DOES in fact upload the images consistently now. I just have to figure out how to do proper image type/size checking and generate thumbs. Then I have to figure out how to extract the image names and thumb names for updating the db. And I'm pretty sure this ALL has to be done within the 'while loop' because I tried echoing the image names after the loop/upload and it doesn't work.
  7. Its not really that long and I thought it might be beneficial to anyone trying to help me out, to post the entire code (just the portions that deal with adding a new ad). Here it is: function add_ad() { global $userdata, $mostweeks, $defaultweeks, $adstext, $locale, $max_img, $db_prefix; echo " <table border='0' cellspacing='2' cellpadding='3' width='100%'> <tr><td>"; $mainlink = 1; menu($mainlink); echo " </td></tr> <tr><td colspan='2'></td></tr> <tr><td class='small' colspan='2'><br />"; SearchForm(); echo " </td></tr> <tr><td colspan='2'></td></tr> <tr><td colspan='2'><b>".$locale['CLS_0031']."</b></td></tr> <tr><td colspan='2'></td></tr>"; if (iMEMBER) { echo " <tr><td>".$locale['CLS_0005']." <b>".$userdata['user_name']."</b>, ".$locale['CLS_0032']."</td></tr> <tr><td></td></tr> <tr><td> <form enctype='multipart/form-data' name='inputform' method='post' action='".FUSION_SELF."?op=Add'> <table> <tr><td>".$locale['CLS_0033']."</td> <td><SELECT class='textbox' name='cat'>"; echo "<option value=''>".$locale['CLS_0034']."</option>\n"; $result = dbquery("SELECT cid, title, parentid FROM ".DB_CLASSIFIED_CATEGORIES." WHERE status='1' ORDER BY parentid,title"); while(list($cid2, $ctitle2, $parentid2) = dbarraynum($result)) { if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2); echo "<option value='$cid2'>$ctitle2</option>\n"; } echo "</SELECT> </td></tr> <tr><td>".$locale['CLS_0035']."</td><td><input class='textbox' type='text' name='title' size='45' maxlength='100' /></td></tr> <tr><td valign='top'>".$locale['CLS_0036']."</td> <td><textarea class='textbox' name='description' cols='40' rows='15' wrap='virtual'></textarea></td></tr></tr> <tr><td> </td><td>"; class_showbbcode('description'); echo "</td></tr> <tr><td> </td><td>"; class_showbbcodecolor('description'); echo "</td></tr> <tr><td> </td><td>".$locale['CLS_0037']."$adstext characters.</td></tr> <tr><td>".$locale['CLS_0025']."</td><td><input class='textbox' type='text' name='url' size='45' maxlength='100' value='http://' /></td></tr>"; for($i=1; $i<=$max_img; $i++){ echo "<tr><td>".$locale['CLS_0103']."$i:</td><td> <input id='adimg' class='textbox' type='file' name='adimg[]' size='45' maxlength='150'></td></tr>"; } echo "<tr><td>".$locale['CLS_0030'].":</td><td>"; prweek($mostweeks, $defaultweeks); echo " ".$locale['CLS_0040']."</td></tr> <tr><td colspan='2' align='center'> <input type='hidden' name='owner' value='".$userdata['user_name']."' /> <input type='hidden' name='owner_id' value='".$userdata['user_id']."' /> <input type='hidden' name='op' value='Add' /> <input class='button' type='submit' name='submit' value='".$locale['CLS_0038']."' /> </td></tr> </table> </form> </td></tr>"; } else { echo " <tr> <td> <p>".$locale['CLS_0039']."</td> </tr>"; } echo " </table>"; } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ function Add($cat, $title, $description, $url, $weeks, $owner, $owner_id) { global $adstext, $locale, $userdata, $settings, $db_prefix; //require_once INCLUDES."photo_functions_include.php"; $postdate = time(); $expiredate = $postdate + (3600 * 24 * $weeks); $url = explode("http://", $url); if ($url[1]=="") { $myurl = ""; } else { $myurl ="$url[1]"; } // Check if Category exist if ($cat=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0041']."<br />"; exit(); } // Check if Title exist if ($title=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0042']."<br />"; exit(); } // Check if ads text exist if ($description=="") { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0043']."<br />"; exit(); } // Check ads text length if (strlen($description) > $adstext) { echo "<br />"; $mainlink = 1; menu($mainlink); echo "<br /><br />".$locale['CLS_0044'].": $adstext characters.<br />"; exit(); } $title = addslashes($title); $description = addslashes($description); // ad image upload if(isset($_POST[submit])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; move_uploaded_file($source, $target); } } // end ad image upload $result = dbquery("INSERT INTO ".DB_CLASSIFIED." VALUES(NULL, '$cat', '$title', '$description', '$myurl', '$postdate', '$expiredate', '$owner', '$owner_id','0','$img1','$img2','$img3','$img4','$img5','$img6','$thb1','$thb2','$thb3','$thb4','$thb5','$thb6')"); $result = dbquery("delete low_priority FROM ".DB_CLASSIFIED." WHERE(expiredate < '$postdate')"); echo $locale['CLS_0108']; redirect(FUSION_SELF."?op=view_ad&cid=$cat",'2'); } All main script areas(functions) are called from a 'switch' setup at the very end of the main script just to clarify.
  8. OK; I don't quite understand whats happening now... I implemented the code changes and WALLA! the 6 files were uploaded! Seemed great. But then I deleted the files on the server to try again(was trying to implement saving to db; that didn't work); so I deleted that save to db code and now, it WILL NOT upload images again with subsequent test posts. Doesn't make sense to me. I figured maybe cookies/sessions/variables not cleared so I logged on and off my site several times. That has not helped. I don't understand. Here is the code now: // ad image upload if(isset($_POST[submit])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name'][$key]; $source = $_FILES['adimg']['tmp_name'][$key]; $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; move_uploaded_file($source, $target); } } // end ad image upload
  9. You were right. I should've been checking for (submit). Thanks! This is what I have in place now: // ad image upload if(isset($_POST[submit])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) { echo $_FILES['adimg']['name'][$key]." | ".$_FILES['adimg']['tmp_name'][$key]."<br /><br />"; } echo "<pre>"; echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; } // $imagename = $_FILES['adimg']['name']; // $source = $_FILES['adimg']['tmp_name']; // $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; // move_uploaded_file($source, $target); // } } // end ad image upload die; And the above produces the following output: windows.gif | /tmp/phpMnDkur POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) themes.gif | /tmp/phpeM6MNI POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) software.gif | /tmp/phpwLtne0 POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) security.gif | /tmp/phpw51ZCh POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) php-fusion.gif | /tmp/phpSGxXJB POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) network.gif | /tmp/phpC8tUOV POST:Array ( [cat] => 8 [title] => Testing [description] => Testing again! [bbcolor] => [url] => http://somewhere.net [weeks] => 7 [owner] => Gargon [owner_id] => 1 [op] => Add [submit] => Submit ) FILES:Array ( [adimg] => Array ( [name] => Array ( [0] => windows.gif [1] => themes.gif [2] => software.gif [3] => security.gif [4] => php-fusion.gif [5] => network.gif ) [type] => Array ( [0] => image/gif [1] => image/gif [2] => image/gif [3] => image/gif [4] => image/gif [5] => image/gif ) [tmp_name] => Array ( [0] => /tmp/phpMnDkur [1] => /tmp/phpeM6MNI [2] => /tmp/phpwLtne0 [3] => /tmp/phpw51ZCh [4] => /tmp/phpSGxXJB [5] => /tmp/phpC8tUOV ) [error] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) [size] => Array ( [0] => 5160 [1] => 5075 [2] => 5607 [3] => 5454 [4] => 5494 [5] => 5503 ) ) ) I tried uncommenting the upload/save portion and it hangs the server; so my question is still; how do I code it correctly to actually upload and save the images??
  10. I'm trying to get this down to just basics first. Below is the code I am trying to use now to upload 6 images(or less) to my 'save dir'. It does not work; nothing is saved in the upload dir. What am I doing wrong here?? The input portion: for($i=1; $i<=$max_img; $i++){ echo "<tr><td>".$locale['CLS_0103']."$i:</td><td> <input id='adimg' class='textbox' type='file' name='adimg[]' size='45' maxlength='150'></td></tr>";} The upload/save portion: // ad image upload if(isset($_POST[adimg])) { while (list ($key, $value) = each($_FILES['adimg']['tmp_name'])) { if (!empty ($value)) $imagename = $_FILES['adimg']['name']; $source = $_FILES['adimg']['tmp_name']; $target = INFUSIONS.'classified_ads_panel/images/ads/'.$imagename; move_uploaded_file($source, $target); } } // end ad image upload
  11. Good morning mrMarkus (or anyone that may have some time to look at this); OK... tried your code and it gives me the output I was looking for. Let me lay the whole thing out and see if I can explain what I am trying to accomplish here. 1) These are the dbFields where the images and thumbs will be stored: img1 varchar(100) NOT NULL default '', img2 varchar(100) NOT NULL default '', img3 varchar(100) NOT NULL default '', img4 varchar(100) NOT NULL default '', img5 varchar(100) NOT NULL default '', img6 varchar(100) NOT NULL default '', thb1 varchar(100) NOT NULL default '', thb2 varchar(100) NOT NULL default '', thb3 varchar(100) NOT NULL default '', thb4 varchar(100) NOT NULL default '', thb5 varchar(100) NOT NULL default '', thb6 varchar(100) NOT NULL default '', 2) This is your code mrMarkus w/my changes: // ad image upload while (list ($key, $value) = each($_FILES['image']['tmp_name'])) { if (!empty ($value)) { echo $_FILES['image']['name'][$key]."_";echo $_FILES['image']['tmp_name'][$key]."<br /><br />"; } } // end ad image upload 3) These are the images of the input/output produced: OOooppss... img input names are from a different test session; but you get the idea... Input Output 4) This is how I need to store the images in db: $img1 = downloads.gif $img2 = hardware.gif $img3 = members.gif $img4 = network.gif $img5 = software.gif $img6 = graphics.gif ---------- $thb1 = downloads_t1.gif $thb2 = hardware_t1.gif $thb3 = members_t1.gif $thb4 = network_t1.gif $thb5 = software_t1.gif $thb6 = graphics_t1.gif Of course these are just test images; actual uploads will almost always be JPGs. I have no idea how to go about saving those uploads into the specified directory; I'm assuming it ALL has to be done within the (while loop) is that right? As well as the thumb creation and save?? Earlier I had tried a slight variation of the very code that you showed me mrMarkus but I got errors saying that I was trying to save array elements instead of strings. So the array elements which contain the image names must first be converted to strings I think. There again I don't know how to go about that. I know this is long-winded and I apologize. If anyone has the time to take a look at this and help me I will be most appreciative.
  12. You sir, are absolutely right and I apologize for my earlier statement. I'll try what you propose and see if it will help. Thanks
  13. Not really solved but I've come to expect little help here lately for some reason. Plus I discovered a lot more resources on the web that I haven't exhausted yet so; I'll figure it out myself.
  14. The problem is: I get nothing echoed to the screen so my question is am I going about this the right way and is my input routine correct? If I can get the input routine to work right then I can convert the array elements to strings for actual uploading and saving to the upload directory. And THEN I can figure out the db update process.
  15. If you examine the code, I'm looking for '$picture' to be echoed to the screen 6 times showing the 6 images w/local computer urls for upload and then die so it doesn't continue script execution.
×
×
  • 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.