robert.access Posted January 25, 2010 Share Posted January 25, 2010 Hi all! so, all it's working fine but I want to upload images in a subdomain like www2.domain.com So here : $uploadfileF = 'www2/images/img_' if I put: $uploadfileF ='http://www2.domain.com/images/img_' i got an error. I am only able to use relative path. Ok if I use www2/images it's loading images fine in directory that I specified but my link for images (on other pages) will be http://www2.domain.com/www2/images/ How can I get off the www2 to be http://www2.domain.com/images/ this is in function uploadfileF Please help! Really apreciate. Thanks <?php session_start(); set_time_limit(0); //This function required to allow users upload pictures with spaces function sanitize_var($value) { if (!is_numeric($value)) { $value = ereg_replace("[^A-Za-z0-9_ ]", "", $value); $value = eregi_replace('amp','and',$value); $value = eregi_replace('quot','',$value); $value = eregi_replace('039','',$value); $value = eregi_replace(' ','-',$value); } return $value; } include('files/config.php'); require_once "lib/JsHttpRequest/JsHttpRequest.php"; $JsHttpRequest =& new JsHttpRequest("windows-1251"); if($_REQUEST["delete"]!='yes'){ $db = new database; $db->connect($db_host, $db_username, $db_password); $db->select_db($db_name); $_RESULT = array( "q" => 'file ' . $_FILES['q']['name'], "md5" => md5(@file_get_contents($_FILES['q']['tmp_name'])), ); $ftmp = $_FILES['q']['tmp_name']; $fname = $_FILES['q']['name']; $fsize = $_FILES['q']['size']; $ftype = $_FILES['q']['type']; $allowedExtensions[] = "jpg"; $allowedExtensions[] = "gif"; $allowedExtensions[] = "png"; $allowedExtensions[] = "jpeg"; $allowedExtensions[] = "avi"; $allowedExtensions[] = "mpeg"; $allowedExtensions[] = "mpg"; $allowedExtensions[] = "mov"; $path_info = pathinfo($fname); if (!in_array(strtolower($path_info['extension']), $allowedExtensions)) { print "<strong>File not allowed to upload</strong>"; die(); } $uploadfileF = 'www2/images/img_'.$_REQUEST['id'] .sanitize_var($fname).'.'.$path_info['extension']; //filename if (move_uploaded_file($ftmp, $uploadfileF)) { mysql_query("DELETE FROM " . DB_PREFIX . "auction_media WHERE auction_id='".$_REQUEST['id']."' AND `order`='".$_REQUEST['order']."' AND media_type='".$_REQUEST['type']."'"); mysql_query("INSERT INTO " . DB_PREFIX . "auction_media (media_url, media_type, auction_id, `order`) values ('".$uploadfileF."','".$_REQUEST['type']."','".$_REQUEST['id']."','".$_REQUEST['order']."')"); } if ($_REQUEST['type']==1){ $image_resize = mysql_fetch_array(mysql_query("SELECT images_max_size, watermark_size FROM " . DB_PREFIX . "gen_setts WHERE 1")); $image_info = getimagesize($uploadfileF); if(($image_resize["images_max_size"]*1024)<$fsize) { print "<strong>File Too Big</strong>"; unlink($uploadfileF); mysql_query("DELETE FROM " . DB_PREFIX . "auction_media WHERE auction_id='".$_REQUEST['id']."' AND `order`='".$_REQUEST['order']."' AND media_type='".$_REQUEST['type']."'"); die(); } if ($image_resize["watermark_size"]<$image_info[0]){ $image = new SimpleImage(); $image->load($uploadfileF); $image->resizeToWidth($image_resize["watermark_size"]); $image->save($uploadfileF); } print "<img src='thumbnail.php?pic=".$uploadfileF."&w=104&sq=Y&b=Y' border='0'>||".$uploadfileF; } else { print "<img src='thumbnail.php?pic=images/media_icon.gif&w=104&sq=Y&b=Y' border='0'>||".$uploadfileF; } } else { $db = new database; $db->connect($db_host, $db_username, $db_password); $db->select_db($db_name); $picture_unlink=mysql_fetch_array(mysql_query("SELECT media_url FROM " . DB_PREFIX . "auction_media WHERE auction_id='".$_REQUEST['id']."' AND `order`='".$_REQUEST['order']."' AND media_type=".$_REQUEST['type'])); if (isset($picture_unlink["media_url"])){ mysql_query("DELETE FROM " . DB_PREFIX . "auction_media WHERE auction_id='".$_REQUEST['id']."' AND `order`='".$_REQUEST['order']."' AND media_type=".$_REQUEST['type']); //unlink($picture_unlink["media_url"]); } print "<img src='images/bg_no_image.gif' height='104px'>"; } ?> Link to comment https://forums.phpfreaks.com/topic/189760-can-anybody-help-me-with-this-serve-images-from-subdomain/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.