-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a parameter for the function setFileToSend, showing up in the Browser instead of to download. #853
Comments
$this->response->setHeader('Cache-Control', 'max-age=3600');
$this->response->setContentType('image/jpeg');
$this->response->setFileToSend($filename, NULL, FALSE);
$this->response->send(); ext/http/response.c: PHP_METHOD(Phalcon_Http_Response, setFileToSend){
zval *file_path, *attachment_name = NULL, *attachment = NULL, *base_path = NULL;
zval *headers, *content_description, *content_disposition;
zval *content_transfer;
PHALCON_MM_GROW();
phalcon_fetch_params(1, 1, 1, &file_path, &attachment_name, &attachment);
if (!attachment_name) {
PHALCON_INIT_VAR(attachment_name);
}
if (!attachment) {
PHALCON_INIT_VAR(attachment);
ZVAL_BOOL(attachment, 1);
}
if (Z_TYPE_P(attachment_name) != IS_STRING) {
PHALCON_INIT_VAR(base_path);
phalcon_call_func_p1(base_path, "basename", file_path);
} else {
PHALCON_CPY_WRT(base_path, attachment_name);
}
PHALCON_INIT_VAR(headers);
phalcon_call_method(headers, this_ptr, "getheaders");
if (zend_is_true(attachment)) {
PHALCON_INIT_VAR(content_description);
ZVAL_STRING(content_description, "Content-Description: File Transfer", 1);
phalcon_call_method_p1_noret(headers, "setraw", content_description);
PHALCON_INIT_VAR(content_disposition);
PHALCON_CONCAT_SV(content_disposition, "Content-Disposition: attachment; filename=", base_path);
phalcon_call_method_p1_noret(headers, "setraw", content_disposition);
PHALCON_INIT_VAR(content_transfer);
ZVAL_STRING(content_transfer, "Content-Transfer-Encoding: binary", 1);
phalcon_call_method_p1_noret(headers, "setraw", content_transfer);
}
phalcon_update_property_this(this_ptr, SL("_file"), file_path TSRMLS_CC);
RETURN_THIS();
} |
Well, - PHALCON_INIT_VAR(headers);
- phalcon_call_method(headers, this_ptr, "getheaders");
if (zend_is_true(attachment)) {
+ PHALCON_INIT_VAR(headers);
+ phalcon_call_method(headers, this_ptr, "getheaders"); |
thank you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ex:
The text was updated successfully, but these errors were encountered: