Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


move_uploaded_file - windows XP

Postades av 2003-03-02 18:56:33 - Maria Frost, i forum php, Tråden har 2 Kommentarer och lästs av 1112 personer

Hej!

Jag har problem med att spara uppladdade bildfiler på min windows-server.

Plattform: PHP Version 4.3.1, Windows XP Professional

Jag får följande meddelande när jag kör scriptet nedan:
Warning: move_uploaded_file(C:/Program/Apache Group/Apache2/htdocs/fredrik/bildarkiv/) [function.move-uploaded-file]: failed to create stream: Permission denied

<code>
mkdir($path, 0777);
move_uploaded_file($_FILES['minibild']['tmp_name'], $path );
</code>
Att skapa katalogen funkar bra, men funktionen för att flytta filen genererar alltså felet. Jag har även testat att skapa katalogen själv och ändra rättigheterna på servern, men det blir samma reslutat.

Jag har uteslutit möjligheten att det blir fel i själva uploaden till servern eftersom funktionen is_uploaded_file($_FILES['minibild']['tmp_name']) returnerar true.

Tacksam för idéer på vad som kan vara fel.

/Maria


Svara

Sv: move_uploaded_file - windows XP

Postades av 2003-03-02 23:14:38 - Håkan Borneland

Här nedan finns ett par inlägg om "move_uploaded_file".
Kanske kan du utifrån vad som skrivs här hitta lösningen på ditt problem.
Fanns en del att tänka på... :-)

/Håkan

<code>

User Contributed Notes
move_uploaded_file
&#106;&#107;&#97;&#112;&#108;&#97;&#110;
01-Jan-2002 02:23

Watch out: The 'string filename' in the function description
move_uploaded_file (string filename, string destination)
is not the file name but the file itself i.e. $userfile, not $userfile_name [$userfile is the name given in the upload form to the 'imput name="userfile" type="file"] See: Chapter 19. Handling File Uploads for more details.


tfaith at 2wgmultimedia dot com
11-Jan-2002 09:08

Hi, for those using NT with PHP, the move_uploaded_file syntax may be confusing. There are 3 things to remember to do: 1. the I_usr account on your server must have rights to the temp folder that php stores its temporary files, and also to the destination folder that you wish to copy a 'good' file. 2. the syntax for the path of the move command requires both a folder and the actual name of the posted file that is to exist on the server. eg, 'g:\\tmp\\'.$userfile_name unless, of course, you mean to save all of your files in the root of the drive! 3. you will need to make your path with two slashes like this -- g:\\tmp\\filename -- because a single slash from php escapes the next character, and that will make NT fretful.


kdechant at midwestarts dot com
25-Jun-2002 05:06

On one of my servers, the files created by this function are owned by nobody (Apache) and have a mode of 600 (only Apache can read/write). The files work properly in the browser, but you might need to run a chmod before you can download them through FTP.


patrick at mokolabs dot com
22-Jul-2002 04:39

If you're validating image uploads by reading MIME types, here's a gotcha to look out for.

Progressive JPEGs are sometimes tagged as 'image/pjpeg'--instead of the more common 'image/jpeg'. (Windows reads 'image/pjpeg', while the Mac reads 'image/jpg')

So if you're testing for valid JPEG files, make sure your code accounts for both potential MIME types!


kdechant at midwestarts dot com
30-Jul-2002 01:10

A followup to my note above about the files having a mode 600 and owner nobody:

I handle this by calling the PHP chmod function immediately after saving the file. Here is an example:

move_uploaded_file($temp_filename, $destination_filename);
chmod($destination_filename, 0644);

Mode 0644 (the zero is required) will allow everyone to read but not modify the file. That allows you to download it with FTP. You can use 0666 if you need to overwrite the file with FTP, but that is probably less secure.


dan at dksdevelopment dot com
19-Sep-2002 11:42

Be sure to set the permissions of the directory of your script to permit writes.


martijnt at dataserve dot nl
22-Jan-2003 10:20

Hi,
it would be nice to mention that you HAVE to use full pathnames (not symlinks) for this function to work...

Happy coding.

Martijn Tigchelaar.


mirrorball_girl at yahoo dot com
11-Feb-2003 09:28

I was having problems with corrupted uploaded image files. If anyone is experiencing the same problem, I solved it using copy($_FILE['image']['tmp_name'], $_FILE['image']['name']) instead of move_uploaded_file($_FILE['image']['tmp_name'], $_FILE['image']['name']);


allen at brooker dot gb dot net
12-Feb-2003 03:48

The first comment totally threw me off. Under the 'new regime', the 'string filename' is $_FILES['userfile']['tmp_name']

Also note that the 'string destination' should be the full path and filename. As long as your server isnt using virtual hosting, you should be able to use $_SERVER['DOCUMENT_ROOT'] . "path/within/website". This'll save hours of hassle trying to get sometimes ignorant ISPs to give you your full and 'no symlinks' path.

Allen


info at phpcoding dot net
26-Feb-2003 04:23

It seems (using php 4.2.3) that it does not work to use umask() with uploaded files. Use the chmod() function as noted above to set the correct permissons on the uploaded file.

</code>



Svara

Sv: move_uploaded_file - windows XP

Postades av 2003-03-03 13:11:21 - Maria Frost

Tack för hjälpen!
Jag ändrade metodens andra argument till att innehålla även ett filnamn på den flyttade filen.
<code>
move_uploaded_file($_FILES['minibild']['tmp_name'], $path . "bild.jpg");
</code>

/Maria


Svara

Nyligen

  • 18:37 Remove the bumper in AUDI
  • 15:35 Chicken road crash game
  • 21:41 Automotive Services UK
  • 20:44 Erfarenhet av CBD-olja mot sömnpro
  • 12:13 Sex Dolls for Sale
  • 19:42 Online Casinos for Haitian Players
  • 19:38 Rekommendera något intressant
  • 19:13 Международная перевозка грузов

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 570 889
27 965
271 778
528
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies