Avatar of doctorbill
doctorbill
Flag 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
PHPWeb Browsers

Avatar of undefined
Last Comment
doctorbill

8/22/2022 - Mon
Julian Hansen

how are you uploading the file? Source code?
Dave Baldwin

For us to help you, you need to give us enough information to examine the problem.
Dave Baldwin

This is a test upload using Chrome 19 and it seems to work fine.
WebSiteDesignOutline.pdf
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Julian Hansen

Ignore - misread above - how do you delete a comment?
doctorbill

ASKER
I will post the source code as soon as I can
doctorbill

ASKER
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)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Julian Hansen

Ok - but we need the client side code as well....
doctorbill

ASKER
This is on my local computer. I just use a browser box to submit the file to this code
Julian Hansen

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?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
doctorbill

ASKER
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)
Julian Hansen

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 ...
doctorbill

ASKER
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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Ray Paseur

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
doctorbill

ASKER
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
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
doctorbill

ASKER
I will try to do this tonight
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
doctorbill

ASKER
Very fast response and very relevant answers