I doing an ajax file uploadusing jquery.form.js. After uploading I send back the uploaded files’ id from PHP to tpl(Smarty).Problem is that now I’m getting the tpl twice. When I put an exit command in the php file I can solve this problem, but then I will not get the value of the returned file’s …
via PHP Website Development » Search Results » ajax:
Iam doing an ajax file upload , but after uploading the form
I doing an ajax file uploadusing jquery.form.js.
After uploading I send back the uploaded files’ id from PHP to tpl(Smarty).
Problem is that now I’m getting the tpl twice. When I put an exit command in the php file I can solve this problem, but then I will not get the value of the returned file’s id to tpl.
Now I would like to get the returned file key in tpl, and also want to display the tpl only once.
if(isset($input[‘act’]) and trim($input[‘act’]) == “uplaodFile”)
$valid_formats = array(“jpg”, “png”, “gif”, “bmp”);
$name = $_FILES[‘photoimg’][‘name’];
$size = $_FILES[‘photoimg’][‘size’];
if(strlen($name))
list($txt, $ext) = explode(“.”, $name);
if(in_array($ext,$valid_formats))
if($size<(1024*1024))
$actual_image_name = time().substr(str_replace(” “, “_”, $txt), 5).”.”.$ext;
$tmp = $_FILES[‘photoimg’][‘tmp_name’];
if($filekey = $files->uploadFile($contact_id, $wrkspace_id, $_FILES[‘photoimg’], “files”, null))
$smarty->assign(“filekey”,$filekey);
}
else
Error::setError (“Image file size max 1 MB”);
}
else
Error::setError(“Invalid file format..”);
}
else
Error::setError(“Please select image..!”);
//EXIT;
}
display(“schedule_event”);
For more info: Iam doing an ajax file upload , but after uploading the form
PHP Website Development » Search Results » ajax