this code is to add image but it didnot work can any one help me please on this code when i run this code it gives me all time message "error" <? $file_type =array('.gif', '.jpg', '.jpeg', '.Bmp'); $size =600000000000; $path ="http://mysite/newsss/admin/up/up"; // the place where i put on it the image $ext =strrchr($file_name,"."); $file_name ="news_".rand().$ext; $url_up="http://mysite/newsss/admin/up/up";// if ($file_name =="") { print "choose the image"; } else { if(file_exists($path."/".$file_name)) { print "this image is exist"; } else { if($file_size > $size) { print "the size too large"; } else { if(!in_array($ext , $file_type)) { print "error"; } else { ( move_uploaded_file($_POST[file] ,$path."/".$file_name)) or print "error"; print "<center><font size='1' face='MS Sans Serif'>ok it upload<br>admin/up/up/$file_name<br> </font><palign='center'> <p align='center'><img border='0' src='up/$file_name'width='120' height='120'></p> "; } } } } ?> and on the other page i make a form and file browse to choose the image <input type="file" name="file" size="21" >
Try this <? $allowed_extensions = array("gif", "jpg", "png", "jpe", "jpeg"); $size =600000000000; $path ="http://mysite/newsss/admin/up/up"; // the place where i put on it the image $ext =strrchr($file_name,"."); $img_name_arr = explode(".",$file_name); $type = end($img_name_arr); $file_name ="news_".rand().$ext; $url_up="http://mysite/newsss/admin/up/up";// if ($file_name =="") { print "choose the image"; } else { if(file_exists($path."/".$file_name)) { print "this image is exist"; } else { if($file_size > $size) { print "the size too large"; } else { if(!(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ) { print "error"; } else { ( move_uploaded_file($_POST[file] ,$path."/".$file_name)) or print "error"; print "<center><font size='1' face='MS Sans Serif'>ok it upload<br>admin/up/up/$file_name<br> </font><palign='center'> <p align='center'><img border='0' src='up/$file_name'width='120' height='120'></p> "; } } } } ?>
i need to upload images and this code make that but there is something missing or wrong i donot know why this code not working???? please help me