//do whatever else needs to be done (insert information into database, etc...)
to owszem kod się wykona ale mimo wszystko stronka wraca do pozycji startowej czego ja bym nie chciał. Proszę o pomoc w tej sprawie.
Aby było łatwiej to wrzucam pliki z kodem:
plik -upload.php
<?php //get unique id ?> <?php //process the forms and upload the files //specify folder for file upload $folder = "../Files/"; //specify redirect URL $redirect = "upload.php?success"; //upload the file //do whatever else needs to be done (insert information into database, etc...) //redirect user //header('Location: '.$redirect); die; } // ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Upload your file</title> <!--Progress Bar and iframe Styling--> <link href="style_progress.css" rel="stylesheet" type="text/css" /> <!--Get jQuery--> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"></script> <!--display bar only if file is chosen--> <script> $(document).ready(function() { // //show the progress bar only if a file field was clicked var show_bar = 0; $('input[type="file"]').click(function(){ show_bar = 1; }); //show iframe on form submit $("#form1").submit(function(){ if (show_bar === 1) { $('#upload_frame').show(); function set () { } setTimeout(set); } }); // }); </script> </head> <body> <h1>Upload your file </h1> <div> <span class="notice">Your file has been uploaded.</span> <?php } ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> Choose a file to upload<br /> <!--APC hidden field type="hidden"--> <!----> <input name="file" type="file" id="file" size="30"/> <!--Include the iframe--> <br /> <iframe id="upload_frame" name="upload_frame" > </iframe> <br /> <!-- frameborder="0" border="0" src="" scrolling="no" scrollbar="no"--> <input name="Submit" type="submit" id="submit" value="Submit" /> </form> </div> </body> </html>
plik- upload_frame.php
<?php //Get file upload progress information. $status = apc_fetch('upload_'.$_GET['progress_key']); die; } // ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"></script> <link href="style_progress.css" rel="stylesheet" type="text/css" /> <script> $(document).ready(function() { // setInterval(function() { //get request to the current URL (upload_frame.php) which calls the code at the top of the page. It checks the file's progress based on the file id "progress_key=" and returns the value with the function below: }, function(data) //return information back from jQuery's get request { $('#progress_container').fadeIn(100); //fade in progress bar $('#progress_bar').width(data +"%"); //set width of progress bar based on the $status value (set at the top of this page) $('#progress_completed').html(parseInt(data) +"%"); //display the % completed within the progress bar } )},500); //Interval is set at 500 milliseconds (the progress bar will refresh every .5 seconds) }); </script> <body style="margin:0px"> <!--Progress bar divs--> <div id="progress_container"> <div id="progress_bar"> <div id="progress_completed"></div> </div> </div> <!----> </body> <?php /* * Server Requirements * PHP 5.2 or greater * APC Make sure you have APC installed on your server. It won't work without it. It's easy to install, so if you don't have root acces to your server, ask your hosting provider to take care of it for you. Installation instructions: Linux | Windows Important: Make sure to include apc.rfc1867 = on in your php.ini file after APC is installed. Your php.ini file should be located at /etc/php.ini. */ ?>