I am wanting to add a default preview image here that would be super ceded if a user uploads their own preview image. Can anyone tell me how to modify this code so I could achieve this. //upload photo preview $_FILES["preview2"]['name']=result_file($_FILES["preview2"]['name']); $nf=explode(".",$_FILES["preview2"]['name']); if((strtolower($nf[count($nf)-1])=="jpg" or strtolower($nf[count($nf)-1])=="jpeg" or strtolower($nf[count($nf)-1])=="gif" or strtolower($nf[count($nf)-1])=="png") and !eregi("text",$_FILES["preview2"]['type'])) { if($_FILES["preview2"]['size']>0 and $_FILES["preview2"]['size']<2048*1024) { $vp=site_root."/content/".$folder."/thumb.".$nf[count($nf)-1]; move_uploaded_file($_FILES["preview2"]['tmp_name'],$_SERVER["DOCUMENT_ROOT"].$vp); if(strtolower($nf[count($nf)-1])=="jpg" or strtolower($nf[count($nf)-1])=="jpeg") { $size = getimagesize ($_SERVER["DOCUMENT_ROOT"].$vp); $wd1=$site_thumb_width; $wd2=$site_thumb_width2; if(isset($size[1])) { if($size[0]<$size[1]){$wd1=$size[0]*$site_thumb_height/$size[1];$wd2=$size[0]*$site_thumb_height2/$size[1];} } easyResize($_SERVER["DOCUMENT_ROOT"].$vp,$_SERVER["DOCUMENT_ROOT"].$vp,100,$wd1); } $swait=true; $sql="update audio set photo='".result($vp)."' where id_parent=".$id; $db->execute($sql); } } } }
None of this code has to do with what you want...you need to add that on the insert not update. BTW here is some revised code. //upload photo preview $_FILES["preview2"]['name']=result_file($_FILES["preview2"]['name']); $nf=explode(".",strtolower($_FILES["preview2"]['name'])); $allowedExts=array('jpg','jpeg','png','gif'); if(in_array($nf[count($nf)-1],$allowedExts) && !eregi("text",$_FILES["preview2"]['type'])) { if(intval($_FILES["preview2"]['size']) and intval($_FILES["preview2"]['size'])<2048*1024) { $vp=site_root."/content/".$folder."/thumb.".$nf[count($nf)-1]; move_uploaded_file($_FILES["preview2"]['tmp_name'],$_SERVER["DOCUMENT_ROOT"].$vp); if(strtolower($nf[count($nf)-1])=="jpg" or strtolower($nf[count($nf)-1])=="jpeg") { $size = getimagesize ($_SERVER["DOCUMENT_ROOT"].$vp); $wd1=$site_thumb_width; $wd2=$site_thumb_width2; if(isset($size[1])) { if($size[0]<$size[1]) { $wd1=$size[0]*$site_thumb_height/$size[1]; $wd2=$size[0]*$site_thumb_height2/$size[1]; } } easyResize($_SERVER["DOCUMENT_ROOT"].$vp,$_SERVER["DOCUMENT_ROOT"].$vp,100,$wd1); } $swait=true; $sql="update audio set photo='".result($vp)."' where id_parent=".$id; $db->execute($sql); } } PHP:
Thanks, I'm very new.I guess I gave it away... Well thanks for the help. Updated how? New and Improved? I am afraid to add, very quirky script.
Well, i'd be willing to help with anything, just feel free to ask. I added a few sanity checks and changed how things are checked. Example is the extensions, they are now an array instead. Just compare the code and you'll find the differences.
I thank you kindly. I received a parse error Parse error: syntax error, unexpected $end in ....../upload_audio.php on line 270