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

  • SEARCH
  • Home
  • 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 9142767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:51:32+00:00 2026-06-17T09:51:32+00:00

http://www.shedlimited.debrucellc.com The site allows users to upload an image, via PHP script(ajaxupload.php) which is

  • 0

http://www.shedlimited.debrucellc.com

The site allows users to upload an image, via PHP script(ajaxupload.php) which is stored in $uploaded_img , inside of the php script. I want to pass the PATH of my newly stored image to a JS file, and the only way I’ve found to do it is by writing the value to a text file, which is extreme overkill

file_put_contents("testFile.txt", "");
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

$stringData = $upload_image;
fwrite($fh, $stringData);
$stringData = "\n";
fwrite($fh, $stringData);
fclose($fh);

At the same time, I have an external .js file running which loads my html5 Canvas etc,

I set a global variable sourcer , inside the external .js file, which I’m able to access and update from my index.php by reading the URL from the file which I wrote the url to in my php script.:

jQuery.get('scripts/testFile.txt', function(data) {
sourcer = data;
});

Is there any way that I can pass the URL value to sourcer without having to manually insert it in a text file?

  • 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-17T09:51:33+00:00Added an answer on June 17, 2026 at 9:51 am

    Add a block to your head on your php template.

    <script type="text/javascript">
        var uploaded_img = '<?php echo json_encode($uploaded_img); ?>';
    </script>
    

    The json encode makes sure the variable is properly encoded, even if it is an object or array.

    If it is purely an ajax thing. Just return the filename in your ajax response.
    So post to your ajax upload, and make your ajax script return a json object with the filename.

    So in your upload script, at he bottom:

    header('Content-type: application/json');
    echo json_encode(array('filename'=>$uploaded_img));
    

    And read the response.filename in javascript.

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

Sidebar

Related Questions

http://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.google.com How can I customize the text and image. It looks like Facebook pulled
http://www.christywhiteheadphotography.com/CWPTEST/ (wordpress site) Part of my theme uses the widgets shown under the slider.
http://www.koolfree.com/ImageUpload/uploads/1340729929.jpg (Table Image) Hello, I have linked to an Image (because stackoverflow was not
http://www.trafficestimate.com/,http://getclicky.com/,http://technotarget.com/find-out-who-is-visiting-your-site-website-traffic-tools/,http://pmetrics.performancing.com/ The above are sample websites for trimming. I want to extract only the
http://www.queness.com/post/328/a-simple-ajax-driven-website-with-jqueryphp I'm trying to get the above script to work, but with some changes.
http://www.plus2net.com/php_tutorial/array_checkbox.php the link is my reference in PHP i want to ask how can
http://www.dscredstorm.com/getisbninfo.aspx I'm trying to use Amazon's api. I downloaded their example code, which is
http://www.avenuesocial.com/ plz check this site and please help me to find out this slider
http://www.question-defense.com/wp-content/uploads/2009/02/intel-945gm-driver.gif how to create an application which displays output which i want the user
http://www.stellarwebsolutions.com/en/articles.php I just got the .pem to work with paypal but I cannot find

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.