Encrypted File is corrupted when uploaded to server via HTTP Post

0

i am making an application which has a function that it encrypt file and then upload it to the server via HTTP POST. I tried it and it works fine when i test it on localhost (Local Server on my same machine).

However now when i try it with a url of a public server with same server side php code, files are uploaded but they are corrupted.

However if the file is not encrypted even if it is binary data, it works fine. Can you tell me what could be the problem, or is it the server does not allow encrypted files?

I am confused because for the server, it should be just another binary data file, then why does it only get corrupted when it is encrypted, while otherwise it works fine. Or may be it is free hosting, that is the reason?

Johnydep

Posted 2012-01-29T22:23:27.217

Reputation: 815

How do you determine if the file is corrupted? – Der Hochstapler – 2012-01-29T22:25:58.023

@OliverSalzburg, by trying to decrepit it. It is simple AES-256 encryption done by 7zip command line tool, and the same tool (or any other winrar e.g) can decrypt those files easily. I tested them on two different machine on my PC's (WAMP server), and it is fine, but when i upload them over internet on this free hosting, i can not decrepit the files, which is not understandable for me? – Johnydep – 2012-01-29T22:33:33.983

OK, so i just uploaded the file to their server via ftp (without using my code but via their web cpanel) and now when i download it back, it is corrupted, so i am pretty sure the problem is with their file system or something like that. But it is strange – Johnydep – 2012-01-29T22:35:33.060

1@OliverSalzburg OK I got it. I was uploading correctly, but i was downloading in ASCII mode, and being encrypted it was not working. I just downloaded the same file uploaded from my code, in binary mode, and it is valid archive... – Johnydep – 2012-01-29T22:54:18.663

1Great! Remember, you can answer your own question. – Der Hochstapler – 2012-01-29T22:57:59.467

No answers