Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #12726

Re: Phonegap upload issue with PHP server

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.php
Subject Re: Phonegap upload issue with PHP server
Date 2014-01-30 11:31 +0000
Organization A noiseless patient Spider
Message-ID <lcdd6m$2ds$2@dont-email.me> (permalink)
References <eb014c74-865d-48ae-beac-b26b4c555675@googlegroups.com>

Show all headers | View raw


On Thu, 30 Jan 2014 02:48:17 -0800, Saikat Saha wrote:

> Hi, I am using the below phonegap code to upload my file to remote PHP
> server and I am able to upload the file even  I am getting response 200
> ok but on the PHP server my file is not getting received even the array
> is empty

> <?php
> 
>   print_r($_FILES);

If the $_FILES array is empty at this point, the the possibilities that 
come to mind are:

1) Your javascript is broken
2) Something is blocking the file upload
3) A webserver configuration issue (see 2)

Have you tried using a very simple html form based upload instead? That's 
a lot simpler to code in html than all that javascript, and should at 
least enable you to verify that it is (or is not) possible to transfer 
files from the browser to the server.

<html>
<head>
<title>test upload</title>
</head>
<body>
<form enctype="multipart/form-data" action="" method="POST">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
<pre>
<?php
if ( isset( $_FILES['userfile'] ) )
    print_r( $_FILES );
else
    echo "Nothing";
?>
</pre>
</body>
</html>

I assume that https://testserver.com/FileUpload/upload_file.php is a url 
that you have crafted to conceal the actual url, otherwise you might want 
to change it to the actual webserver url you are using.

I have no idea what the purpose of the js to set options.mimeType to 10 
or so different values one after the other is - but it ends up as "video/
ogg" - if this is meant to be the mimetype of the uploaded file then the 
method of determining and setting it appears flawed.

In fact I have no idea what most of the js is meant to do, and if the 
above mentioned php test proves that the simple file upload from your 
browser to your server is working, I suggest you find a phonegap forum 
for more specific assistance with your problem.

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Phonegap upload issue with PHP server Saikat Saha <saikat.saha5@gmail.com> - 2014-01-30 02:48 -0800
  Re: Phonegap upload issue with PHP server Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-30 11:31 +0000
  Re: Phonegap upload issue with PHP server Saikat Saha <saikat.saha5@gmail.com> - 2014-01-31 02:36 -0800
    Re: Phonegap upload issue with PHP server Jerry Stuckle <jstucklex@attglobal.net> - 2014-01-31 08:51 -0500
    Re: Phonegap upload issue with PHP server Luuk <luuk@invalid.lan> - 2014-01-31 14:49 +0100
  Re: Phonegap upload issue with PHP server JohnT <john-sospam@jtresponse.co.uk> - 2014-01-31 12:55 +0000

csiph-web