Web Hosting Forum | Lunarpages

Author Topic: upload stopped working?  (Read 750 times)

Offline NDF

  • Intergalactic Superstar
  • *****
  • Posts: 151
    • http://www.andyfoulds.co.uk
upload stopped working?
« on: February 18, 2017, 03:04:15 PM »
Hi,
this PHP file:

<?php
if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
// Get the data
$imageData=$GLOBALS['HTTP_RAW_POST_DATA'];

// Remove the headers (data:,) part.
// A real application should use them according to needs such as to check image type
$filteredData=substr($imageData, strpos($imageData, ",")+1);

// Need to decode before saving since the data we received is already base64 encoded
$unencodedData=base64_decode($filteredData);

//echo "unencodedData".$unencodedData;
$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false);
// Save file. This example uses a hard coded filename for testing,
// but a real application can specify filename in POST variable
$fp = fopen( 'upload/' . $fn, 'w' );
fwrite( $fp, $unencodedData);
fclose( $fp );
}
?>

was working up until mat least 03/03/2016 (date the last image was uploaded) but is now not working. What's changed? I'm no PHP/server expert so any help would be much appreciated.
www.andyfoulds.co.uk
_________________________

Offline NDF

  • Intergalactic Superstar
  • *****
  • Posts: 151
    • http://www.andyfoulds.co.uk
Re: upload stopped working?
« Reply #1 on: February 18, 2017, 04:19:24 PM »
And this is the code that calls it - it traces 'success':

                        m1 = 'upload/'+dropOneName;

                        var xhr = new XMLHttpRequest();

         if (xhr.upload/* && dropFile.type == "image/jpeg" && file.size <= $id("MAX_FILE_SIZE").value*/) {
            xhr.onreadystatechange = function(e) {
               if (xhr.readyState == 4) {
               var progress = (xhr.status == 200 ? "success" : "failure");
               console.log("progress = "+progress)
               }
            };
            xhr.open("POST", "upload.php"/*$id("upload").action*/, true);
            xhr.setRequestHeader("X_FILENAME", dropOneName);
            xhr.send(drop01);
            console.log('dropOneName = '+dropOneName)

         }
www.andyfoulds.co.uk
_________________________

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6207
Re: upload stopped working?
« Reply #2 on: February 18, 2017, 04:55:48 PM »
You haven't updated your code in almost a year? Get your site (WordPress?) up to date first, and see if the problems go away. LP has recently upgraded many servers to PHP 5.6, and it's possible that older WP sites will no longer work correctly.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline NDF

  • Intergalactic Superstar
  • *****
  • Posts: 151
    • http://www.andyfoulds.co.uk
Re: upload stopped working?
« Reply #3 on: February 18, 2017, 06:40:34 PM »
It's not a WP site?
www.andyfoulds.co.uk
_________________________

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6207
Re: upload stopped working?
« Reply #4 on: February 18, 2017, 06:50:59 PM »
OK, if it's not WordPress, is it a canned application from someone else? The first thing to check is whether it's been updated recently, and whether your version runs on your server's PHP level (probably 5.6 now). If you're running an old version, it may very well not run on current PHP levels. I presume you didn't write it yourself, but did someone else do it for you if it's not an off-the-shelf canned application?
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline NDF

  • Intergalactic Superstar
  • *****
  • Posts: 151
    • http://www.andyfoulds.co.uk
Re: upload stopped working?
« Reply #5 on: February 18, 2017, 07:20:09 PM »
Completely self-built, although the PHP was tweaked from some I found on the web as I'm a noob at backend stuff.
I've changed nothing recently but it just stopped working. Traces as 'success' and the site will still load images uploaded earlier but new uploads don't make it into my server, causing 404s.

From the code I supplied is there anything I need to tweak for PHP 5.6?
Any changes to server security?

Thanks
Andy____F
« Last Edit: February 18, 2017, 07:36:34 PM by NDF »
www.andyfoulds.co.uk
_________________________

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6207
Re: upload stopped working?
« Reply #6 on: February 19, 2017, 06:30:15 AM »
You had me confused there, describing yourself as "no PHP expert" but then showing some sophisticated XML/HTTP stuff that I'm not familiar with. Anyway, was your server at PHP 5.3 or so when you last ran this successfully, and it's now at 5.6? That upgrade has broken a lot of stuff. Have any support libraries (PHP code, JS code, etc.) been upgraded by their suppliers? Upgrading them would be the first thing to do. The PHP site (php.net) offers a number of guides for upgrading from one PHP version to another, so that would be the next place to look. Beyond that, a place like StackOverflow might be useful.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

 

Share |