Hej! Här nedan finns ett par inlägg om "move_uploaded_file". Tack för hjälpen!move_uploaded_file - windows XP
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.
/MariaSv: move_uploaded_file - windows XP
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
jkaplan
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>
Sv: move_uploaded_file - windows XP
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