Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyświetlanie linku po zakończonym uploadzie
qwert89
post 16.04.2010, 20:55:23
Post #1





Grupa: Zarejestrowani
Postów: 5
Pomógł: 0
Dołączył: 16.04.2010

Ostrzeżenie: (0%)
-----


Witam,
korzystam z uploadera dostępnego pod tym adresem: http://freeajaxscripts.net/directory/Ajax_...er/details.html
Brakuje mi w nim funkcji wyświetlenia linku wysłanego pliku tak, aby można go skopiować. Jest możliwość jakiegoś prostego rozwiązania?
index.php
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Max's AJAX File Uploader</title>
  6. <link href="style/style.css" rel="stylesheet" type="text/css" />
  7.  
  8. <script language="javascript" type="text/javascript">
  9. <!--
  10. function startUpload(){
  11. document.getElementById('f1_upload_process').style.visibility = 'visible';
  12. document.getElementById('f1_upload_form').style.visibility = 'hidden';
  13. return true;
  14. }
  15.  
  16. function stopUpload(success){
  17. var result = '';
  18. if (success == 1){
  19. result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
  20. }
  21. else {
  22. result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
  23. }
  24. document.getElementById('f1_upload_process').style.visibility = 'hidden';
  25. document.getElementById('f1_upload_form').innerHTML = result + '<label>File: <input name="myfile" type="file" size="30" /><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>';
  26. document.getElementById('f1_upload_form').style.visibility = 'visible';
  27. return true;
  28. }
  29. //-->
  30. </script>
  31. </head>
  32.  
  33. <body>
  34. <div id="container">
  35. <div id="header"><div id="header_left"></div>
  36. <div id="header_main">Max's AJAX File Uploader</div><div id="header_right"></div></div>
  37. <div id="content">
  38. <form action="upload.php" method="post" enctype="multipart/form-data" target="upload_target" onsubmit="startUpload();" >
  39. <p id="f1_upload_process">Loading...<br/><img src="loader.gif" /><br/></p>
  40. <p id="f1_upload_form" align="center"><br/>
  41. <label>File:
  42. <input name="myfile" type="file" size="30" />
  43. </label>
  44. <label>
  45. <input type="submit" name="submitBtn" class="sbtn" value="Upload" />
  46. </label>
  47. </p>
  48.  
  49. <iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
  50. </form>
  51. </div>
  52. <div id="footer"><a href="http://www.ajaxf1.com" target="_blank">Powered by AJAX F1</a></div>
  53. </div>
  54.  
  55. </body>



upload.php
  1. <?php
  2. // Edit upload location here
  3. $destination_path = getcwd().DIRECTORY_SEPARATOR;
  4.  
  5. $result = 0;
  6.  
  7. $target_path = $destination_path . basename( $_FILES['myfile']['name']);
  8.  
  9. if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
  10. $result = 1;
  11. }
  12.  
  13. sleep(1);
  14. ?>
  15.  
  16. <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script>


Pozdrawiam smile.gif

Ten post edytował qwert89 16.04.2010, 22:05:30
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 03:52