Quantcast
Channel: HTML5
Viewing all articles
Browse latest Browse all 663

Intel XDk HTML5 file uploads to PHP server script

$
0
0

Good day,

I have spent many days learning and have progressed quite a bit but I am stilling missing the plot somewhere and would appreciate your guidance.

I have successfully build a number of pages that respectively can take pictures and I got a PHP server script running that receives the picture upload. One problem here is that the same image is uploaded every time and not the new picture taken.

I have further successfully got the geolocation feature working perfectly

Lastly I got the QR code reader working fine.

My problem is the following: I do not quite understand the concept of creating a text file and capture an image and uploading this on the same page within the app. My objective is as follows: To take a picture, add related and relevant text, then add the geolocation where the picture was taken. This I then want to upload to my web server using a PHP server side script. Lastly I need to write the info to a sql database. I would really apprectiate some guidance and/or examples.

I am pastinfg the current PHP script that work for the image on the server side below

<?php

ob_start();
echo "<pre>";
print_r($_FILES);
print_r($_GET);
print_r($_POST);

echo "</pre>";

print_r("file type: " . $_FILES["Filedata"]["type"]);

$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["Filedata"]["name"]);
$extension = end($temp);
if ((($_FILES["Filedata"]["type"] == "image/gif")
|| ($_FILES["Filedata"]["type"] == "image/jpeg")
|| ($_FILES["Filedata"]["type"] == "image/jpg")
|| ($_FILES["Filedata"]["type"] == "image/pjpeg")
|| ($_FILES["Filedata"]["type"] == "image/x-png")
|| ($_FILES["Filedata"]["type"] == "image/png"))
&& ($_FILES["Filedata"]["size"] < 9999999999)
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["Filedata"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["Filedata"]["error"] . "<br>";
    }
  else
    {
    echo "Upload: " . $_FILES["Filedata"]["name"] . "<br>";
    echo "Type: " . $_FILES["Filedata"]["type"] . "<br>";
    echo "Size: " . ($_FILES["Filedata"]["size"] / 1024) . " kB<br>";
    echo "Temp file: " . $_FILES["Filedata"]["tmp_name"] . "<br>";

    if (file_exists("upload/" . $_FILES["Filedata"]["name"]))
      {
      echo $_FILES["Filedata"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["Filedata"]["tmp_name"],
      "upload/" . $_FILES["Filedata"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["Filedata"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
  
  $data=ob_get_clean();
$fp=fopen("debug.txt","w+");
fputs($fp,$data);
fclose($fp);
?>


Viewing all articles
Browse latest Browse all 663


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>