stelthius Posted July 20, 2009 Share Posted July 20, 2009 Hello guys, Im using define("DN_IMG_PATH", "IMG/"); define("DN_PDF_PATH", "PDF/"); To define the url to my PDF & IMG Dir's but when i use it like that it gives me LINK/home/php_work/public_html/Listings/admin/PDF/listings-yKCZXf.pdf But when i do it like this define("DN_IMG_PATH", "/home/php_work/public_html/Listings/admin/IMG/"); define("DN_PDF_PATH", "/home/php_work/public_html/Listings/admin/PDF/"); It stores the upload image and pdf in the /temp/ DIR and then displays the image link as LINK/temp/listings-yKCZXf.pdf Can anyone see what im doing wrong here as this is confusing me now. Regards rick. Link to comment https://forums.phpfreaks.com/topic/166659-help-with-img-pdf-dir/ Share on other sites More sharing options...
stelthius Posted July 20, 2009 Author Share Posted July 20, 2009 After alot of fiddling and no luck ive begun to think its the way im uploading the file but i really cannot see anything wrong with it here is my uploading code.. 1'st part. define("DN_IMG_PATH", "IMG/"); define("DN_PDF_PATH", "PDF/"); function handle_upload($file_id,$path,$suffix){ $source = $file_id['tmp_name']; $dest = tempnam($path,"lamont-"); if( (isset($file_id['name'])) && ($file_id['name'] != "") ) { copy($source,$dest); if($suffix!=""){ $new = $dest.$suffix; rename($dest,$new); $dest = $new; } chmod($dest,0777); } else { $dest = ""; } return $dest; } And here is the 2'nd part if ($_FILES['pimage_file']['size']!=0) { if($prpID){ delete_old_image($dbConn,$prpID); } $pimage_temp = handle_upload($_FILES['pimage_file'],DN_IMG_PATH,".jpg"); $pimage_fname = $_FILES['pimage_file']['name']; } else { if($prpID){ $result = getPropertyByID($dbConn,$prpID); $row = mysql_fetch_assoc($result); $pimage_temp = $row['prp_image_temp_name']; $pimage_fname = $row['prp_image_orig_name']; } } if ($_FILES['ppdf_file']['size']!=0) { if($prpID){ delete_old_pdf($dbConn,$prpID); } $ppdf_temp = handle_upload($_FILES['ppdf_file'],DN_PDF_PATH,".pdf"); $ppdf_fname = $_FILES['ppdf_file']['name']; } *Edit* When it uploads the temp file its uploading it with the full path to the img such as, /home/php_work/public_html/Listings/admin/IMG/listings-Lgeu0U.jpg Any help is greatly appretiated Rick. Link to comment https://forums.phpfreaks.com/topic/166659-help-with-img-pdf-dir/#findComment-878843 Share on other sites More sharing options...
stelthius Posted July 20, 2009 Author Share Posted July 20, 2009 Alright so looking at this more, i thought about ways to use explode, but i really have no clue about using the explode function ive looked over on the manul but that didnt help me either i think its because ive been trying to figure it out that long im getting annoyed with it. Can anyone offer some support ? here is my full page so you can see everything its doing. <?php require_once("db.php"); define("DN_IMG_PATH", "IMG/"); define("DN_PDF_PATH", "PDF/"); function handle_upload($file_id, $path, $suffix) { $source = $file_id['tmp_name']; $dest = tempnam($path, "lamont-"); if ((isset($file_id['name'])) && ($file_id['name'] != "")) { copy($source, $dest); if ($suffix!="") { $new = $dest.$suffix; rename($dest, $new); $dest = $new; } chmod($dest, 0777); } else { $dest = ""; } return $dest; } $title=checkPostValue("ptitle", $_POST); $paddr1 = checkPostValue("paddr1", $_POST); $paddr2 = checkPostValue("paddr2", $_POST); $ptown = checkPostValue("ptown", $_POST); $pcounty = checkPostValue("pcounty", $_POST); $postcode = checkPostValue("postcode", $_POST); $ptype1 = checkPostValueNum("ptype1", $_POST); $ptype2 = checkPostValueNum("ptype2", $_POST); $ptype3 = checkPostValueNum("ptype3", $_POST); $ptype4 = checkPostValueNum("ptype4", $_POST); $pdescription = checkPostValue("pdescription", $_POST); $psize = checkPostValueNum("psize", $_POST); $psize2 = checkPostValueNum("psize2", $_POST); $pcategory1 = checkPostValueNum("pcategory1", $_POST); $pcategory2 = checkPostValueNum("pcategory2", $_POST); $pcategory3 = checkPostValueNum("pcategory3", $_POST); $pcategory4 = checkPostValueNum("pcategory4", $_POST); $pcategory5 = checkPostValueNum("pcategory5", $_POST); $pcategory6 = checkPostValueNum("pcategory6", $_POST); $published = checkPostValueNum("published", $_POST); $price = checkPostValue("price", $_POST); $prpID = checkPostValue("prpID", $_POST); if ($psize==false) { $psize=0; } if ($psize2==false) { $psize2=0; } if ($psize<0) { $psize=0; } if ($psize2<0) { $psize2=0; } if (($psize==0) && ($psize2!=0)) { $psize = $psize2; } if (($psize!=0) && ($psize2==0)) { $psize2 = $psize; } if ($psize>$psize2) { $x = $psize; $psize = $psize2; $psize2=$x; } if ($_FILES['pimage_file']['size']!=0) { if ($prpID) { delete_old_image($dbConn, $prpID); } $pimage_temp = handle_upload($_FILES['pimage_file'],DN_IMG_PATH, ".jpg"); $pimage_fname = $_FILES['pimage_file']['name']; } else { if ($prpID) { $result = getPropertyByID($dbConn, $prpID); $row = mysql_fetch_assoc($result); $pimage_temp = $row['prp_image_temp_name']; $pimage_fname = $row['prp_image_orig_name']; } } if ($_FILES['ppdf_file']['size']!=0) { if ($prpID) { delete_old_pdf($dbConn, $prpID); } $ppdf_temp = handle_upload($_FILES['ppdf_file'],DN_PDF_PATH, ".pdf"); $ppdf_fname = $_FILES['ppdf_file']['name']; } else { if ($prpID) { $result = getPropertyByID($dbConn, $prpID); $row = mysql_fetch_assoc($result); $ppdf_temp = $row['prp_pdf_temp_name']; $ppdf_fname = $row['prp_pdf_orig_name']; } } print $result_array = array ("title"=>$title, "addr1"=>$paddr1, "addr2"=>$paddr2, "addr3"=>"", "town"=>$ptown, "county"=>$pcounty, "postcode"=>$postcode, "ptype1"=>$ptype1, "ptype2"=>$ptype2, "ptype3"=>$ptype3, "ptype4"=>$ptype4, "pdescription"=>$pdescription, "psize"=>$psize, "psize2"=>$psize2, "pcategory1"=>$pcategory1, "pcategory2"=>$pcategory2, "pcategory3"=>$pcategory3, "pcategory4"=>$pcategory4, "pcategory5"=>$pcategory5, "pcategory6"=>$pcategory6, "published"=>$published, "pimage_name"=>$pimage_fname, "pdf_name"=>$ppdf_fname, "pimage_temp"=>$pimage_temp, "pdf_temp"=>$ppdf_temp, "price"=>$price); if (isset($_POST['prpID']) && $_POST['prpID']!="") { update_property($dbConn, $result_array, $_POST['prpID']); } else { insert_property($dbConn, $result_array); } printf("<script>location.href='index.php'</script>"); ?> With regards rick. Link to comment https://forums.phpfreaks.com/topic/166659-help-with-img-pdf-dir/#findComment-879021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.