Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]upload nie dziala, Walczę z tym dwa dni i nic
Johnas
post
Post #1





Grupa: Zarejestrowani
Postów: 650
Pomógł: 16
Dołączył: 5.07.2010
Skąd: Ściśle Tajne

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


Dla czego nie chce mi owy skrypt wgrać pliku na serwer. W folderze mam ustawione chmody 777 ale dalej mi nie działa.
Pokazuje cały czas komunikat "Wystąpił problem z wgraniem zdjęcia na serwer."

PHP:
  1. if ($_POST['config']){
  2. $plik_nazwa = trim($_POST['plik_nazwa']);
  3. $plik_tmp = $_FILES['foto']['tmp_name'];
  4. $plik_nazwa = $_FILES['foto']['name'];
  5. $ext = pathinfo($plik_nazwa, PATHINFO_EXTENSION);
  6. $kodowanie = md5($_POST['plik_nazwa']);
  7. $lacz = $kodowanie.$ext;
  8. $image = $_POST['image'];
  9. $url = $_POST['url'];
  10. if ($url == 1) {
  11. $onurl = 1;
  12. $urladres = $_POST['adresurl'];
  13. } else {
  14. $onurl = 0;
  15. $urladres = 'brak';
  16. }
  17.  
  18. if ($image == 1) {
  19. $obrazek = $_POST['adresimage'];
  20. } else if ($image == 2) {
  21. if (strlen($_POST['foto']) > 1){
  22. $obrazek = 'upload/pop.jpg';
  23. } else {
  24. $blad++;
  25. echo '<div class="error">Proszę wybrać plik z dysku do załadowania</div>';
  26. }
  27. } else {
  28. $blad++;
  29. echo '<div class="error">Nie zaznaczono opcji wstawienia obrazka.</div>';
  30. }
  31. if (strlen($obrazek) < 1) {
  32. $blad++;
  33. echo '<div class="error">Nie podano adresu do obrazka.</div>';
  34. }
  35. if (strlen($urladres) < 1) {
  36. $blad++;
  37. echo '<div class="error">Porszę wprowadzić adres do odnośnika.</div>';
  38. }
  39. if ($blad == 0){
  40. if ($image == 2) {
  41. if(is_uploaded_file($plik_tmp)) {
  42. move_uploaded_file($plik_tmp, "../upload/$lacz");
  43. $wynik03 = mysql_query("UPDATE pop SET url='$urladres', on_url='$onurl', img='$obrazek' WHERE
  44. id='1'");
  45. if ($wynik03){
  46. echo '<div class="success">Pop został ustawiony na stronie.</div>';
  47. } else {
  48. echo '<div class="error">Wystąpił problem z Bazą danych. Prosimy spróbować ponownie później. Jeżeli problem będzie się powtarzać to proszę to zgłosić firmie fine-design</div>';
  49. }
  50. } else {
  51. echo '<div class="error">Wystąpił problem z wgraniem zdjęcia na serwer.</div>';
  52. }
  53. }
  54. }
  55. }


HTML:
  1. <form action='' method='post'>
  2. <input type='hidden' name='config' value='TRUE'/>
  3.  
  4.  
  5. <table border="1" rules="none">
  6. <tr>
  7. <td colspan="2"><center><b>Obrazek</b></center></td>
  8. </tr>
  9. <tr>
  10. <td width="125"><input type='radio' name='image' value='1' onclick="document.getElementById('obrazek2').style.display='none'; document.getElementById('obrazek1').style.display = this.checked ? 'block' : 'none'; this.form.elements['nazwa2'].disabled = this.form.elements['nazwa3'].disabled = !this.checked" /> Adres url</td>
  11. <td width="125"><input type='radio' name='image' value='2' onclick="document.getElementById('obrazek1').style.display='none'; document.getElementById('obrazek2').style.display = this.checked ? 'block' : 'none'; this.form.elements['nazwa2'].disabled = this.form.elements['nazwa3'].disabled = !this.checked" /> Z dysku</td>
  12. </tr>
  13. <tr>
  14. <td colspan="2">
  15. <div id='obrazek1' style='display: none'>
  16. <center>Adres obrazka:<input type='text' name='adresimage' /></center>
  17. </div>
  18. <div id='obrazek2' style='display: none'>
  19. <center>Plik do wysłania: <input name="foto" type="file" /></center>
  20. </div>
  21.  
  22. </td>
  23. </tr>
  24. <tr><td colspan="2"><hr></td></tr>
  25. <tr>
  26. <td colspan="2"><center><b>Odnośnik</b></center></td>
  27. </tr>
  28. <tr>
  29. <td colspan="2"><input type='checkbox' name='url' value='1' onclick="document.getElementById('odnosnik').style.display = this.checked ? 'block' : 'none'; this.form.elements['nazwa2'].disabled = this.form.elements['nazwa3'].disabled = !this.checked" /> Włącz</td>
  30. </tr>
  31. <tr>
  32. <td colspan="2">
  33. <div id='odnosnik' style='display: none'>
  34. <center>Adres odnośnika:<input type='text' name='adresurl' /></center>
  35. </div>
  36. </td>
  37. </tr>
  38. <tr>
  39. <td colspan="2"><center><input type='submit' value='Wyślij' ></center></td>
  40. </tr>
  41. </table>
  42.  
  43. </form>
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 22.08.2025 - 14:25