feri_soft Posted January 3, 2007 Share Posted January 3, 2007 I have 2 arrays:[code=php]<?phpforeach ($_FILES[images][name] as $img) { $ext123 = substr(strrchr($img, "."), 1); if(($ext123 == "jpg") || ($ext123 == "jpeg") || ($ext123 == "gif")){}else{ $error[] = "ERROR";}}?>[/code]which is before my database queryand[code=php]<?php while(list($key1,$value1) = each($_FILES[images][name])) { if(!empty($value1)) { $ext1 = substr(strrchr($value1, "."), 1); $filename = $idlast . ' - ' . $key1 . '.' . $ext1; echo $filename; $add = "upload/$filename"; copy($_FILES[images][tmp_name][$key1], $add); $add = trashinput($add); $fq = "UPDATE listings SET img". $key1 ." = '$add' WHERE id = '$idlast'"; mysql_query($fq) or die('Грешка : ' . mysql_error()); } }?>[/code]which is after the query.The first one checks the file extension and if they are good it proceeds if not it dies. The second is after the query so that i can get the last id and put it as a file name. But when i put the first array check it doesn't want to upload files. When i remove it, it works more than perfect.Can you tell me where is the problem or suggest another way of uploading with id names ;) Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 3, 2007 Share Posted January 3, 2007 just having a quick look at your code there I have a question[code]<?phpforeach ($_FILES[images][name] as $img) { $ext123 = substr(strrchr($img, "."), 1); if(($ext123 == "jpg") || ($ext123 == "jpeg") || ($ext123 == "gif")){ //what am i to do if the extensions is a jpg/jpeg/gif...you have not told me to do anything}else{ $error[] = "ERROR";}}?>[/code]sorry I have read my post and realised that if they are that then dont throw and error but carry on I will have another think - apologies Quote Link to comment Share on other sites More sharing options...
feri_soft Posted January 3, 2007 Author Share Posted January 3, 2007 No problem, just having some trouble with !== so i have changed a bit any other suggestions?? Quote Link to comment Share on other sites More sharing options...
paul2463 Posted January 5, 2007 Share Posted January 5, 2007 !== means is NOT IDENTICAL TO!= means NOT EQUAL TO so you could try and use[code]<?phpforeach ($_FILES[images][name] as $img) { $ext123 = substr(strrchr($img, "."), 1); if(($ext123 != "jpg") || ($ext123 != "jpeg") || ($ext123 != "gif")) { $error[] = "ERROR"; }}?>[/code] Quote Link to comment Share on other sites More sharing options...
taith Posted January 5, 2007 Share Posted January 5, 2007 something to that effect maybe?[code]<?phpforeach ($_FILES[images][name] as $img) { $ext123 = substr(strrchr($img, "."), 1); if(!($ext123 == "jpg") || ($ext123 == "jpeg") || ($ext123 == "gif")) $error[] = "ERROR"; else{ if(move_uploaded_file($_FILES["images"]["tmp_name"], $img)){ echo "Magazine Updated!"; }else $error[] = "ERROR"; }}?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.