Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [AJAX][PHP]Problem z pobraniem nazwy uploadowanego pliku
furman12
post 21.02.2010, 17:54:11
Post #1





Grupa: Zarejestrowani
Postów: 118
Pomógł: 4
Dołączył: 3.12.2009

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


Witam mam taki skrypt
  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>Ĺšwinek 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">Plik został załadowany!<?php echo "<strong>$filename</strong>"; ?><\/span><br/><br/>';
  20. }
  21. else {
  22. result = '<span class="emsg">Błąd podczas uploadowania pliku!<\/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">ĹšWINEK 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">Ładowanie...<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"></div>
  53. </div>
  54.  
  55. </body>

który wysyła dane do
  1. <?php
  2. // Edit upload location here
  3. //$destination_path = getcwd().DIRECTORY_SEPARATOR;
  4. $destination_path = "uploads/";
  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. $filename = $_FILES['myfile']['name'];
  12. }
  13.  
  14. sleep(1);
  15. ?>
  16.  
  17. <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script>

Lecz w takiej formie jak jest nie może mi wyświetlić w pierwszym skrypcie nazwy uploadowanego pliku tj w 19 linijce.

Ten post edytował furman12 21.02.2010, 17:56:14
Go to the top of the page
+Quote Post

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: 24.07.2025 - 18:35