if($_FILES["field_your_ profile_photo"]["name"]) {
$filename=uniqid().$_FILES[" field_your_profile_photo"][" name"];
$_FILES["field_your_profile_ photo"]["type"];
$_FILES["field_your_profile_ photo"]["size"];
$_FILES["field_your_profile_ photo"]["tmp_name"];
move_uploaded_file($_FILES[" field_your_profile_photo"][" tmp_name"],$_SERVER['DOCUMENT_ ROOT']."/goodstreet/sites/ default/files/product/" .$filename);
//print $profile->field_business_name[ 'und'][0]['value'];
$image_path = 'public://product/'. $filename;
$image_info = image_get_info($image_path);
//print_r($image_info); exit();
// create file object
$file = new StdClass();
$file->uid = $uid;
$file->uri = $image_path;
$file->filemime = $image_info['mime_type'];
$file->status = 0; // Yes! Set status to 0 in order to save temporary file.
$file->filesize = $image_info['file_size'];
print $file->filename=$filename;
file_save($file);
$profile->field_your_profile_ photo = array(
'und' => array(
0 => array(
'fid' => $file->fid,
'filename' => $file->filename,
'filemime' => $file->filemime,
'uid' => $uid,
'uri' => $file->uri,
'status' => 1
)
)
);
}
No comments:
Post a Comment