login  Naam:   Wachtwoord: 
Registreer je!
 Forum

move_uploaded_file

Offline Diewy - 22/06/2005 19:24
Avatar van DiewyPHP interesse ----------------------
foto_upload.php
----------------------
  1. <?php
  2.  
  3. include("../foto_vars.php");
  4.  
  5.  
  6.  
  7. if(isset($_FILES['file']))
  8. {
  9. if(!$_FILES['file']['size'] < 50000000)
  10. {
  11. if(
  12. $_FILES['file']['type'] == "image/gif"
  13. ||
  14. $_FILES['file']['type'] == "image/pjpeg"
  15. ||
  16. $_FILES['file']['type'] == "image/jpeg"
  17. ||
  18. $_FILES['file']['type'] == "image/png"
  19. )
  20. {
  21. $scan = scandir($dir);
  22. $i = count($scan);
  23. $naam = $i -1;
  24.  
  25. $_FILES['file']['name'] == "$naam";
  26. $_FILES['file']['tmp_name'] == "./uploading";
  27. mkdir("./fotos/".$naam, 0777);
  28. move_uploaded_file($_FILES['file']['tmp_name'], "./fotos/".$naam);
  29.  
  30. if($uitleg != "")
  31. {
  32. file_put_contents("fotos/".$naam."/uitleg.txt", $uitleg);
  33. }
  34. }
  35. else
  36. {
  37. header("Location:$error_type");
  38. }
  39. }
  40. else
  41. {
  42. header("Location:$error_grootte");
  43. }
  44. }
  45.  
  46. else
  47. {
  48. header("Location:$error_geenfile");
  49. }
  50.  
  51. ?>


----------------------
foto_vars.php
----------------------

  1. <?php
  2.  
  3. $uitleg = $_POST['uitleg'];
  4. $dir = "./fotos";
  5.  
  6. //errors
  7. $error_geenfile = "../error/geenfile.php";
  8. $error_grootte = "../error/grootte.php";
  9. $error_type = "../error/type.php";
  10.  
  11. ?>


----------------------
form
----------------------

  1. <form method="post" action="foto_upload.php" enctype="multipart/form-data">
  2.  
  3. <p>
  4. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  5. <tr>
  6. <td valign="top">Foto</td>
  7. <td valign="top">
  8. <input type="hidden" name="MAX_FILE_SIZE" value="5000000">
  9. <input type="file" size="30" name="file">
  10. </td>
  11. </tr>
  12. <tr>
  13. <td valign="top">Uitleg</td>
  14. <td valign="top"><textarea cols="75" rows="6" name="uitleg"></textarea></td>
  15. </tr>
  16. </table>
  17. </p>
  18.  
  19. <p>
  20. <input type="submit" value="Bevestig">
  21. <input type="reset" value="Herbegin">
  22. </p>
  23.  
  24. </form>


-----------------------------------------------------------------------------------

Ik krijg als error:

Citaat:
Warning: move_uploaded_file(./fotos/4) [function.move-uploaded-file]: failed to open stream: Permission denied in c:webserverwwwadminpanelfotosalbumsppfoto_upload.php on line 28

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:/Webservertmpphp185.tmp' to './fotos/4' in c:webserverwwwadminpanelfotosalbumsppfoto_upload.php on line 28



Wat gaat er fout met mijn "move_uploaded_file"?

6 antwoorden

Gesponsorde links
Offline Gerard - 22/06/2005 19:27
Avatar van Gerard Ouwe rakker heb je je directories wel ge-chmod?
Offline Diewy - 22/06/2005 19:30
Avatar van Diewy PHP interesse
  1. mkdir("./fotos/".$naam, 0777);

dan staat die toch op 777?
Offline Legolas - 22/06/2005 19:49
Avatar van Legolas Onbekend ja, maar je hebt mss windows draaien, en die doet wel eens vreemd tijdens chmodden:s
Offline Diewy - 22/06/2005 19:52
Avatar van Diewy PHP interesse Ik test idd voorlopig nog gewoon op localhost, en die draait op mijn windows baksken hier...

en valt daar niks aan te doen? 
Offline Legolas - 22/06/2005 19:57
Avatar van Legolas Onbekend PHP.net comment:
Citaat:
about chmod,
Problably you have a local server to simulate your scripts before upload them to the server. No matter if you use Apache under windows or IIS , a chmod instruction like chmod($filename,O777) may not work because windows does not handle that kind of permission's format.
So being in your local server, if you have a only read file and you try to erase, it will show that you dont have permissions even when you have already executed your chmod instrucction correctly. Just up the script it must work well in your internet server if it is a linux machine
Fernando Yepes C.

Dus een probleem!
Hier een oplossing:
Citaat:
On WinME with apache chmod also works to a certain limit.

What happens is that apparently only the first number is counted, so 0666 (read-write) is the same as 0777, 0644, 0600, etc, and 0444 (read-only) is the same as 477, 400, etc.

..didn't test 0500 series

Werkt ook op WinXP:)
Offline Diewy - 22/06/2005 20:02 (laatste wijziging 22/06/2005 20:03)
Avatar van Diewy PHP interesse Ik heb het al:

  1. $scan = scandir($dir);
  2. $i = count($scan);
  3. $naam = $i -1;
  4.  
  5. $_FILES['file']['name'] = $naam;
  6. mkdir("./fotos/".$naam, 0777);
  7.  
  8. if($_FILES['file']['type'] == "image/gif")
  9. {
  10. move_uploaded_file($_FILES['file']['tmp_name'], "./fotos/".$naam."/".$naam.".gif");
  11. }
  12. if($uitleg != "")
  13. {
  14. file_put_contents("fotos/".$naam."/uitleg.txt", $uitleg);
  15. }


nog even voor de andere extensies maken, et voila 
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.24s