Is there a way I can display a message box saying that the file uploaded is greater than 4 MB.
the following code in the code behind cs file does not work
if (FileUploader.PostedFile.ContentType == "application/pdf" && FileUploader.PostedFile.ContentLength < 4000000)
{
I was able to solve the problem by adding this is to the web.config. No changes to the IIS is made
<system.web>
<httpRuntime maxRequestLength="102400" />
this allowed the following code to execute and the message is displayed successfully
if (FileUploader.PostedFile.ContentType == "application/pdf" && FileUploader.PostedFile.ContentLength < 4000000)
{ ... }
else
{
labelProgrammaticPopup3.Text = "You can only upload valid PDF files of size less than 4 MB.";
this.programmaticModalPopup3.Show();
}
Related
This is my template code:
<croppa
v-model="croppers[i]"
placeholder="Select Image"
initial-size="contain"
:placeholder-font-size="25"
:show-remove-button="false"
:initial-image="initialImages[i]"
></croppa>
This my script to update initial image values for each cropper.
for (i = 0; i < 6; i++) {
this.croppers[i].refresh()
this.imageNames[i] = ''
if (this.editProductFlag && (typeof this.productDetails.images !== 'undefined')) {
if (typeof this.productDetails.images[i] !== 'undefined') {
this.initialImages[i] = this.productDetails.images[i].image
this.imageNames[i] = this.productDetails.images[i].description
}
}
}
This is the error I am getting
Access to image at 'https://dev-pickl-img-static.pickl.pro/product_images/145/good_day5c3104b49e69b.png' from origin 'https://dev-app.pickl.pro' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have tried tag also with crossorigin="anonymous" but still its not working.
Can anyone please help me with this issue?
No, CORS requests do not work as you can think.
You must check the documentation of your image provider and see if there is an option to enable CORS requests, otherwise will never be able to get the images from the frontend.
We are specifically getting this error when using Amazon ec2 instance. Configuration on aws instance is Tomcat 7, Ubuntu 16.04 and memory is 8gb. It occurs when the user tries to view pdf file. In our application, we are having one functionality where the user can only view PDF file onto browser, but won't be able to download it. PDF file is on the same server. We are using cors minimal configuration. We have tried it locally with Ubuntu and it is working fine.
Code snippet:
var fileSplitContent = fileName.split(".");
if ($('#viewImageOnlyForm')[0] != undefined && $('#viewPdfOnlyForm')[0] != undefined) {
if (fileSplitContent[fileSplitContent.length - 1].toLowerCase() != "pdf") {
$('#imageSource').val(requestURL + $.param(inputData));
$('#viewImageOnlyForm').submit();
} else {
var requestURL = "rest/file/getCapitalRaiseFile?";
$('#pdFSource').val(requestURL + $.param(inputData));
$('#viewPdfOnlyForm').submit();
}
} else {
// pop up download attachment dialog box
downloadIFrame.attr("src", requestURL + $.param(inputData));
}
}
Jan 04, 2017 5:07:31 AM org.glassfish.jersey.server.ServerRuntime$Responder writeResponse
SEVERE: An I/O error has occurred while writing a response message entity to the container output stream.
org.glassfish.jersey.server.internal.process.MappableException: org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Connection reset
Caused by: org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Broken pipe (Write failed)
Depending where you access the document this can be because of you have a download manager installed on your browser. This sometimes causes problems - maybe take a look at your extensions. You should try by disabling downloader manager extension in your browser.
I want to install SSL(Comodo wildcard certificate, ex: "*.test.com")
in Vapor Web framework, the "servers.json" I got is:
{
"default": {
"port": "$PORT:443",
"host": "api.test.com",
"securityLayer": "tls",
"tls": {
"certificates": "chain",
"certificateFile": "/path/ssl-bundle.crt",
"chainFile": "/path/ssl-bundle.crt",
"privateKeyFile": "/path/key.pem",
"signature": "signedFile",
"caCertificateFile": "/path/AddTrustExternalCARoot.crt"
}
}
}
I already make sure that "public/private" key matches already using openssl command. And about the certificateFile part like "ssl-bundle.crt", I also tried "*.test.com.crt" with the "key.pem" as well(still pass the validation using openssl, the only difference is one is test.com's certificate, the other is bundle certificate, combined by correct orders already.). Besides, all certs and key's format are correct as well. And I also make sure the cert/key files location is correct so that the Vapor can find these files. But I still can't launch the server correctly, and always display the error.
I try to locate the exact location in xcode, but I can only see it fails in this method: "tls_accept_fds()", which is in tls_server.c of CLibreSSL library.
Also, I saw the error message the xcode displayed to me:
After use debug mode to trace, I can only know that it seems the program throws the error in "SSL_set_rfd()" or "SSL_set_rfd()", but I don't know exactly. The xcode only shows this to me, and I can't find any other error messages in the debug console. As result, so far I can only make sure that the error should be in this block:
int
tls_accept_fds(struct tls *ctx, struct tls **cctx, int fd_read, int fd_write)
{
struct tls *conn_ctx = NULL;
// I pass this block
if ((ctx->flags & TLS_SERVER) == 0) {
tls_set_errorx(ctx, "not a server context");
goto err;
}
// I pass this block
if ((conn_ctx = tls_server_conn(ctx)) == NULL) {
tls_set_errorx(ctx, "connection context failure");
goto err;
}
// I pass this block
if ((conn_ctx->ssl_conn = SSL_new(ctx->ssl_ctx)) == NULL) {
tls_set_errorx(ctx, "ssl failure");
goto err;
}
// I pass this block
if (SSL_set_app_data(conn_ctx->ssl_conn, conn_ctx) != 1) {
tls_set_errorx(ctx, "ssl application data failure");
goto err;
}
// The error occurs here, in SSL_set_rfd or SSL_set_wfd, it will then go to err part: "*cctx = NULL;", not even go into the if block.
if (SSL_set_rfd(conn_ctx->ssl_conn, fd_read) != 1 ||
SSL_set_wfd(conn_ctx->ssl_conn, fd_write) != 1) {
tls_set_errorx(ctx, "ssl file descriptor failure");
goto err;
}
*cctx = conn_ctx;
return (0);
err:
tls_free(conn_ctx);
*cctx = NULL;
return (-1);
}
So, the above is all the info I got right now, and I can't find the solution on the internet for several days already...
Could anyone give me any hint about how to install SSL in Vapor web framework? I can correctly install the SSL in Apache, Nginx, Tomcat, etc already. But never success in Vapor, it seems like C library issue, but I don't know the real reason why it fails, thank you very much for any possible help.
The bug has been found and fixed here: https://github.com/vapor/tls/pull/27
I have tried searching for a relevant answer for this one on all forums , but nothing actually has worked for us as yet. Appreciate if someone can actually help us in this regard as we have an impending release in a few days
We have created a WinJS based windows desktop app which is consuming Oracle SOA based web services (http based) over VPN / or a dedicated APN configuration
whenever we try to access the services we get a Status 0 as return value for xhr ( which is i assume related to response is null ) & get this in the
WinJS.xhr: Network Error 0x2efd, Could not complete the operation due to error 00002efd
We tried using various suggested options like allowing Private Network in the manifest file ( assuming this is a CORS issue) , but to no avail
"Private Networks (Home & Server)"
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
</Capabilities>
We have been working around using Fiddler (loopback option) but that's just temporary , can someone suggest ,what we might be missing or given their experience tell us what could be wrong with our approach.
Any help is really appreciated.
Background
WinJS.XHR returns response.status === 0 when you don't have access to the Internet. Unfortunately this is treated like a success in WinJS 3.0:
if ((req.status >= 200 && req.status < 300) || req.status === 0) {
schedule(c, req, priority);
} else {
schedule(e, req, priority);
}
In WinJS 4.x they changed the condition, so that it :
if ((req.status >= 200 && req.status < 300) ||
(req.status === 0 && options.url.substr(0,7) === 'file://')) {
schedule(c, req, priority);
} else {
schedule(e, req, priority);
}
and more recently in 4.4:
if ((req.status >= 200 && req.status < 300) || (isLocalRequest && req.status === 0)) {
schedule(c, req, priority);
} else {
schedule(e, req, priority);
}
See: https://github.com/winjs/winjs/commit/8d44a3ee4105aa05fb69cd82943b9c07500bf523
This means that on your success promise callback you will receive an empty response.
WinJS.XHR({[...]}).then((response: XMLHttpRequest) => {
// Here response.status === 0 instead of error in the error handler!!!
}, (error) => console.log(error));
Solution
Use Charles Proxy (maybe Fiddler doesn't show responses right) to see what is happening behind the scenes with your request. Most likely fails.
Depending on your version of WinJS use:
a. success handler and output the response when response.status ==== 0
b. error handler and same as above.
Im using 000webhost as a way to host my portfolio of websites. However Im getting this error thrown in which doesn't happen to me on localhost.
Notice (8): Undefined index: Upload [APP/Controller/UploadsController.php, line 32]
This is the code it seems to be referring to,
public function add() {
$this->render();
if($this->request->is('post')){
$file = $this->request->data['Upload']['file'];
if($this->Upload->save($this->data) && move_uploaded_file($file['tmp_name'],APP.'webroot/files/uploads'.DS.$this->Upload->id.'.mp4'))
{
$this->Session->setFlash('<p class="uploadflash">The upload has been saved</p>', true);
$this->redirect(array('controller'=>'Uploads', 'action' => 'watch', $this->Upload->id));
} else {
$this->Session->setFlash('<p class="loginerror">The upload could not be saved, mp4 files can be saved only.</p>', true);
}
}
}
Any ideas as to why this is happening?
Also in addition my Elements are not showing up on this online hosting either?
I get thrown this error on the page
Element Not Found: Elements/uploads/recentuploads.ctp
Does anyone else seem to have this problem??
Upon further inspection I have found that the server does not allow file upload sizes to exceed 2mb, in this instance PHP throws the error above.