thara Posted September 25, 2011 Share Posted September 25, 2011 I have uploaded my music video in to the server and renamed it using songs id as larry teach in chapter 17. It work perfectly, but I retrieve the file in to the download script using their id, songs downloading without it's extension (mp3, wma ete), then users cant play them directly even if they downloaded the songs. so can I rename song's name again in my download script? I use songs id to find the upload file. upload file's name equal to the songs id. Thanks in advance for any help Link to comment Share on other sites More sharing options...
bahaa Posted September 25, 2011 Share Posted September 25, 2011 this is how i do it // check for an image if(is_uploaded_file($_FILES['photo']['tmp_name'])){ //Create a temporary file name $target_path = "../uploads/"; $photo_name = strtolower($_FILES['photo']['name']); $temp_photo_filename = $_FILES['photo']['tmp_name']; $photo_file_size = $_FILES['photo']['size']; $photo_file_type = strtolower($_FILES['photo']['type']); $photo_file_extension = strtolower(substr(strchr($_FILES['photo']['name'],'.'), 1)); $imageInfo = getimagesize($temp_photo_filename); $imageInfo = $imageInfo['mime']; //Convert all applicable characters to HTML entities $photo_file_name = htmlentities($photo_name); $photo_file_type = htmlentities($photo_file_type); $allowed = array('image/pjepg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png', 'image/gif', 'image/GIF'); if(!in_array($photo_file_type, $allowed)){ $errors[]="<p>إمتداد الملف الذي قمت بتحميله غير مصرح به.</p>"; }// end of if(in_array($_FILES['upload']['type'], $allowed)){ if(!is_numeric($photo_file_size)){ $errors[]="<p>نوع الملف الذي تحاول تحميله غير معروف</p>"; }//if(!is_numeric($photo_file_size)){ }//if(is_uploaded_file($_FILES['photo']['tmp_name'])){ Link to comment Share on other sites More sharing options...
bahaa Posted September 25, 2011 Share Posted September 25, 2011 //Move the file over if(is_uploaded_file($_FILES['photo']['tmp_name'])){ if(move_uploaded_file($temp_photo_filename, $target_path.$photo_file_name)){ if(file_exists($target_path. $photo_file_name)){ $unique_photo_name = uniqid(md5(time())).".".$photo_file_extension; rename($target_path.$photo_name, $target_path.$unique_photo_name); }//if(file_exists($target_path. $photo_file_name)){ Link to comment Share on other sites More sharing options...
00cakea Posted February 21, 2012 Share Posted February 21, 2012 I have uploaded my music video in to the server and renamed it using songs id as larry teach in chapter 17. It work perfectly, but I retrieve the file in to the download script using their id, songs downloading without it's extension (mp3, wma ete), then users cant play them directly even if they downloaded the songs. so can I rename song's name again in my download script? I use songs id to find the upload file. upload file's name equal to the songs id. Thanks in advance for any help did you ever solve the problem thara? I'm having similar problem and would be great to get some assistance! Link to comment Share on other sites More sharing options...
Recommended Posts