Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Parse.com: Uploading a File Using the Parse PHP SDK (v1.0.x)

Parse.com: Uploading a File Using the Parse PHP SDK (v1.0.x)

11

Using the official Parse PHP SDK, it’s quite easy to upload a file to Parse. I’ve received a few requests for a tutorial to cover this particular issue, so here it is. I’ve used Parse PHP SDK v1.0.4 for this tutorial, but it will work with older versions too.

Using a simple HTML form and a few lines of PHP, you can upload a file to Parse. As we’re using PHP, the file is first uploaded to your server (in temporary space) and then sent to Parse.

When you create your Parse Class, make sure one column is of type File. In my example, the class TestObject has two columns: foo of type String, and image of type File.

The Code:

The Output:

After selecting a file to upload and submitting it, the above code will output the objectId of the saved object, and the link to the uploaded file:

Parse File Upload - PHP

In Parse, the class should show the uploaded file too (in my example, under the image column). You can click on the file name here to show the uploaded file too.

Parse File Upload - Parse

If you experience any issues with the above code, please let me know in the comment section below.

File Upload, Parse, PHP, Tutorial

11 comments on “Parse.com: Uploading a File Using the Parse PHP SDK (v1.0.x)”

  1. Steven says:
    December 30, 2014 at 3:24 PM

    Thanks Niraj!
    this works perfectly for image uploading and for music uploading I added this added this line below.

    $file = ParseFile::createFromData( file_get_contents( $_FILES[‘mymusic’][‘tmp_name’] ), “newmusic.mp3” );

    Reply
  2. Azhan Hassan says:
    September 30, 2015 at 3:00 AM

    HI Niraj,
    I am trying this code but it’s showing the error about SSL certification.
    How to solve this.

    Reply
    • Niraj Shah says:
      September 30, 2015 at 10:19 AM

      Are you getting this error on a local environment or on your production env?

      Reply
      • Azhan says:
        October 4, 2015 at 9:25 PM

        I’m having this on my local environment

      • Niraj Shah says:
        October 5, 2015 at 10:27 AM

        To fix the issue, you have two options: 1) setup SSL on your local environment using a self-signed certificate. The setup for this will depend on what server software you use. 2) Edit the ParseClient.php file to add the following line to the _request() method:

        curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false);

        Please don’t use this in production environment.

      • Azhan Hassan says:
        October 6, 2015 at 12:16 AM

        I tried the other option with cacert.pem that works fine for me..

  3. Tony says:
    October 3, 2015 at 7:51 PM

    Hello Niraj:

    I have this error : SSL certificate problem: unable to get local issuer certificate.
    I’m working on a local environment (xampp)

    Reply
    • Niraj Shah says:
      October 5, 2015 at 10:28 AM

      Just answered the same problem for another reader

      Reply
      • Jeremy Cugmas says:
        October 6, 2015 at 7:09 PM

        I did the both solution and I still have the same error. I have this error when I do the file->save()

  4. Tony says:
    October 5, 2015 at 4:31 PM

    I put the line: curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false); in the _request function in the ParseClient.php file but the same error : SSL certificate problem: unable to get local issuer certificate.

    Reply
  5. tony says:
    October 6, 2015 at 5:33 PM

    I put the line in ParseClient.php like this :

    $rest = curl_init();
    curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false);

    but still :

    Failed to create new object, with error message: SSL certificate problem: unable to get local issuer certificate

    Reply

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy