Upload data in one tab and see the result in next tab - php

I have a webpage with 2 tabs, one is for uploading data and second is for showing the result. The first tab is a form which is redirected to a php file (upload.php) on submit.
I want to upload data in first tab using php and then without redirecting to another page,go to the next tabb and see the result there.
Can anyone tell me if this is possible to run a php file on the background? I'm so new in php programming and didn't find anything helpful searching my question.

Related

Script to copy website content - not source code

I have a website where the user goes to another website, copies the content, pastes into a text box, and clicks submit. My PHP script parses the content and imports a table into my MySQL database. I am looking to automate this. I know the PHP file_get_contents command will get the source code of a website, but I am looking to get the content as it is displayed on a browser.
The script does not have to be in PHP - I am open to anything. Any suggestions very welcome!
Thanks!

Order php script execution

The problem
My initial php script looked something like this:
echo "text"; // display text
echo "<img src='displaypic.php'>"; // display pic
echo "text"; // display text
I observed that when loading the page the text was displayed first (after 1 or 2 seconds) then the pics (it took a bit longer). That was pretty fine because users were never in front of a blank page.
Later I added a script for displaying a flash pie chart (found the script on Open Flash Chart):
echo "text"; // display text
echo "<img src='displaypic.php'>"; // display pic
echo "text"; // display text
include 'piechart.php'; // display flash chart
It works fine but... all visual content (text, pics, chart) is displayed at once. The problem is that it takes about 10 sec. to load and I think it is just too long.
What I would like to do
Ideally I would like to have text displayed first, followed by pics and chart so users are not in front of a blank page. Is there a simple way to do that? Thanks.
Your question isn't related to PHP execution. Because php usually compiles and executed on server side before your server sends any data to client side. So when you see any result on your webpage it means your php script already completely finished running.
On the other hand displaying some elements first related to how a browser renders html, javascript and css so you can find a solution in those. Changing your table/div etc structure , putting include files to correct positions will make a change about your expected result. But don't forget It can also varies depending on what browser you are using while testing your site.

PHP send data to parent window without using javascript

I am using FPDF to create a pdf document in an iFrame... During the pdf creation the script communicates and gets a lot of data from the server, and then I would like to display a progress bar.. That is why I have put the php generator in an iFrame.. then my plan was that the php script could send the looped data to the parent window..
e.g. every time a loop is made it says $count++;, then I know how many loops it has gone through, and I already know that it is going to limit the rows to the first 200 rows.. Then I would like to display the looped data in the parent widow like so: $count of §goal has been generated successfully!.. At the moment I am using jQuery, where I ask the php to echo some jQuery script every time a loop is made to display the results like so window.parent.count($count, $goal);.. Count in the parent winodw and it actually works well until the PDF has to be shown.. then I get an error message that tells me that the script is unable to display the PDF because the page already has outputted data..
Does anybody know how to make the PHP to send the data to the parent window, so I prevet the using of echo?
Sorry for my bad english.. if wished I can try to upload my script later for you to see...
I do it a bit differently...
I also wrote an application in which the PDF generator needs to fetch a rather large amount of data, so the generation takes a few seconds.
I use jQuery to fetch a php-page in the background. During this download, the screen turns gray and displays a classic "please wait"-circle. The only output that the php-file generates is an "OK" echo, together with a file link, when the generation has been completed. Instead of displaying the file inline, I save the PDF in a folder ($pdf->Output('filename.pdf','S')) and offer it as a download using the provided link and the jQuery-callback.
I hope you understand what I mean. Maybe this thought will help you a bit further.
EDIT: Don't know if this will work, but I just thought of it...
You could save the file and output the filename. Using jQuery, you could then refresh the contents of the iframe to fetch a page in which you display the already saved PDF inline...

Track when a download file dialog appears

I have some links that when the user clicks one, it links to a php script which runs some stored procedures to generate data and then calls another script to download the data as an excel spreadsheet. This all works fine.
What I'd like to do is have a loader gif appear beside the link that was clicked clicked and when the dialog appears to get the user to save the file, have that gif disappear again.
Can I track this event at all to achieve this? Not had much luck so far.
I would call the generate script as ajax, and use the success and error functions to recognize completion of the script? THen you can just start the animation, call your script, and when it returns you can cancel the animation.

running a PHP file in background

I'm building an upload files form, it works fine but now i wanna add some extra features to it, for example,
When I upload the file the page im in sends me to the PHP page, then it echo's a message saying that its done and showing a preview of the image.
What I would like to do now is to stay in the same page as the file is being uploaded, then just get a message in the same page once the file is done uploading. So in other words not be sent to the PHP page instead that info (sent via form POST) can be sent in the background (maybe using XMLHttpRequest?)
Can somebody point me to the right direction to do something like that? i would greatly appreciate it.
Thanks!
You'll have to use javascript and APC_UPLOAD_PROGRESS to monitor the upload. Like this:
http://www.ibm.com/developerworks/library/os-php-v525/index.html
HTH

Categories