Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:19:37+00:00 2026-06-09T11:19:37+00:00

I have this array at the moment which contains a lot of data URIs.

  • 0

I have this array at the moment which contains a lot of data URIs. I set this earlier in the code like this:

dataArray = [];
dataArray.push({name : file.name, value : this.result});

After doing a few things with the data URIs I want to upload them when the user finally presses the upload button, so I pass the data URIs to a PHP file like so:

$.each(dataArray, function(index, file) {   

    $.post('upload.php', dataArray[index], function(data) {

And run a few functions inside to show a loading bar, etc.

Now in the PHP file (upload.php) I have no idea what to do. Each data URI will be posted separately to the PHP file, but how do I treat a data URI in PHP? Usually I would do $_POST to get the data URI itself but I don’t really know how to go about pushing this into a folder on the server. Can I treat the data URI as just a normal file and use $_FILES? So far I haven’t had much success.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:19:39+00:00Added an answer on June 9, 2026 at 11:19 am

    Your POST data will be like this:

    $name = $_POST['name'];
    $value = $_POST['value'];
    

    Before you even touch the values of those variables, need to sanitize all of the variables first and confirm that the $value variable is in fact a valid image file. To do this, you need to convert the data-URI to an actual image.

    To do that, you need to examine the structure of the data-URI:

    data:[<MIME-type>][;charset=<encoding>][;base64],<data>
    

    So in order to parse it, you need to write a regex to extract this information from the data-URI, decode the base64-encoded image data, and finally try to parse it as an image file using the MIME-type. If this fails, the image is corrupted. If not, you can save it to your server.

    It may sound complicated, but I doubt it will take you very long to implement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this array {$man_data} which is structured like 10 > 'Text 8' 14
At the moment I have an array constructed like this: Car[] garage = new
I have this array property in my model and would like to see it
I have this array Array ( [data] => Array ( [0] => Array (
Ok, So I have a 2-d array of data which has the shape(23025, 1000),
I have this piece of code which permits me to print multiple dates, so
I have this array that I am needing to insert into the database. My
i have this array double a[][] = {{1,1,1}, {0,1,1} , { 1,0,0} ,{0,1,0},{1,0,0},{1,0,1},{1,1,1},{1,1,1},{1,0,1},{0,2,0},{0,1,1}}; and
I have this array: $pets = array( 'cat' => 'Lushy', 'dog' => 'Fido', 'fish'
I have this array in PHP: array( [0] => array( 'username' => 'user1' )

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.