Thank you for the consideration, I'm sorry for my non-informative question.
Actually I am using ajax and zend for uploading a file.
My ajax code looks like this:
$.ajax({
type: "POST",
url: "/business_general/imagesave",
enctype: 'multipart/form-data',
data: {'file': files.getAsBinary(), 'fname' : file.fileName},
success: function(arrReturn){
alert( "Data Uploaded: ");
}
});
Here, I called a controller action(imagesave) to save my image in database
My Controller file action looks like this:
$config = Zend_Registry::get('config');
$vehiclelogo = $config->paths->vehiclelogo;
$file = $objRequest->getParam('file');
$ret = $objRequest->getParam('fname');
$path_parts = pathinfo($ret);
echo $path_parts['extension'], "\n";
echo $path_parts['filename'], "\n";
$targetPath = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
try {
echo "POSTED FILE NAME"." ". $ret;
echo "TYPE OF FILE UPLOADED"." "."-". gettype($ret);
$strFilePath = $vehiclelogo.'/'.$targetPath.'.'.$path_parts['extension'];
$OPfile = fopen($strFilePath,"w");
fwrite($OPfile,$file);
fclose($OPfile);
echo "completed";
}
catch (Exception $e) {
echo "error";
}
Here, I am uploading the selected image into a folder.Acually, I am able to upload text files. But if I upload png/jpeg files,it gets uploaded into the folder, But the fact is that it could not be opened.
I should be able to able to upload every type of files.
How to execute this in zend-php and ajax?