Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

google chrome and php

I have a very odd problemkj which has surfaced since installing the latest google chrome browser

I am running php version  5.2.5 and mysql client / server version 5.0.37
Internet explorer version 8 and chrome version 19, 0, 1084, 46 m

I have been using a php script for uploading files for years now - in Internet explorer version 8 and google chrome - with no problems. If I now upload a file to the computer using google chrome and the upload php page, the file is  uploaded but is corrupted. The file cannot be opened by google chrome OR internet explorer (chrome tells me there is an error opening the pdf and internet explore tells me there is no %pdf at start of file) - opening the uploaded file with a hex editor shows no data, or rather just a load of squares
.
If I replace the uploaded file with the original version copied to the upload location, it still cannot be opened by google chrome, but is opened by internet explorer with no problem.
If I upload / reupload the file with internet explorer version 8, the file is ok and it opens with both internet explorer AND google chrome.

Any ideas greatly appreciated
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

how are you uploading the file? Source code?
For us to help you, you need to give us enough information to examine the problem.
This is a test upload using Chrome 19 and it seems to work fine.
WebSiteDesignOutline.pdf
Ignore - misread above - how do you delete a comment?
Avatar of doctorbill

ASKER

I will post the source code as soon as I can
Here is the code:
-------------------------------------
//upload the file if someone selects a file to upload
$form1file = "";

if($_FILES['form1_file'] && $_FILES['form1_file']['size'] > 0){
      $uploaddir = "ticktockInt/documents/Purchases/";  //folder in which to put the file
      $filename = $_FILES['form1_file']['name'];
      $uploadfile = $uploaddir . $_FILES['form1_file']['name'];
      move_uploaded_file($_FILES['form1_file']['tmp_name'], $uploadfile);
      $form1file = $uploaddir.$filename;
      chmod($uploadfile,0777);
}
//
---------------------------------------
Please note the following:
1. Please re-read my notes at the top of the page - these are very relevant
2. This code works with Internet explore version 8
3. I am using Chrome 19.0.1084.46 m
4. This code has been working for years - it has only caused this issue in the last two weeks (after upgrading Chrome I think but I can't be sure on this)
Ok - but we need the client side code as well....
This is on my local computer. I just use a browser box to submit the file to this code
I am confused - please explain the steps you go through to upload your code - the server side code does not really help on its own.

When you say "I just use a browser box" - what do you mean exactly?
The web page has the following code to load a file:
<input name="form1_file" type="file" class="body_bold_blue_10" id="form1_file" />

When the submit button is clicked on the same page, this value is submitted to the script above (on the same page)
Sorry but this is becoming a little bit frustrating

This would usually be encapsulated in a <form></form> element

<input name="form1_file" type="file" class="body_bold_blue_10" id="form1_file" />

Can you post ALL the code for the client side so we can see how the form is defined ...
Sorry for the delay
I have attached the complete form

To help you with the navigation and to save time:
Lines 642 - 798 contains the first form on the page, along with the submit button
Once submitted to the same page, the form variables are sent to the scripts on lines 62 - 107, including the file upload script (one of which is shown below and above):
//upload the file if someone selects a file to upload
$form1file = "";

if($_FILES['form1_file'] && $_FILES['form1_file']['size'] > 0){
      $uploaddir = "ticktockInt/documents/Purchases/";  //folder in which to put the file
      $filename = $_FILES['form1_file']['name'];
      $uploadfile = $uploaddir . $_FILES['form1_file']['name'];
      move_uploaded_file($_FILES['form1_file']['tmp_name'], $uploadfile);
      $form1file = $uploaddir.$filename;
      chmod($uploadfile,0777);
}
//

Hope this is clear
database-records-entry.php
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1. Why is it that uploading in  internet explorer is ok
2. If I replace the corrupted file with the original file in the saved location, Chrome still does not accept it (after closing and opening  the browser) when I click on the link to the file, but internet explorer does
3. If I reupload the file using internet explorer and then open chrome, the link to the file works
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will try to do this tonight
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TarkanErimer
TarkanErimer

As of last monday (May, 21st), I started to experience the same problem. When uploading any kinds (jpg, PDF, doc, xls, zip etc.) of files via HTTPS, it succeeds. Even the files sizes are equal with the original file. But, when downloading back the same file, it's just a corrupted file. When, I've opened those corrupted files, they are just full with (#) hashes. The same thing works fine with IE and Firefox. Also, when uploading from HTTP, it works as well. It only happens via HTTPS connections.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very fast response and very relevant answers