Uploading Files
Posted: Sat May 03, 2003 10:33 am
Hello. I made a little script to upload a jpeg picture to my server and I'm testing it out on my Windows machine. here is the form I use:
and here is submit2.php
The problem is this:
I am running my machine as an administrator with all the priveleges enabled. I have also checked and double checked that the above folders exist, yet it still can't create the file. I am running PHP 4.3.1 on IIS 5.0 with MySQL 3.23.xx. Please help.
Thanks.
Code: Select all
<HTML>
<body>
<form enctype="multipart/form-data" method="POST" action="submit2.php">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<input type="hidden" name"foo" value="bar">
<input type="file" name="fupload"><br>
<input type="submit" value="Send file!">
</form>
</body>
</html>Code: Select all
<?php
$file_dir = "C:\\Inetpub\\wwwroot\\pc-dna\\pics";
$file_url = "http://localhost/pc-dna/pics";
foreach( $HTTP_POST_FILES as $file_name => $file_array ) {
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size: ".$file_array['size']."<br>\n";
if ( is_uploaded_file( $file_array['tmp_name'] )
&& $file_array['type'] == "image/pjpeg" ) {
move_uploaded_file( $file_array['tmp_name'], "$file_dir".$file_name)
or die ("Couldn't copy");
print "<img src="$file_url/$file_name"><p>\n\n";
}
}
echo "Success";
?>Code: Select all
path: C:\WINDOWS\TEMP\php2C.tmp
name: image012.jpg
type: image/pjpeg
size: 6551
Warning: move_uploaded_file(C:\Inetpub\wwwroot\pc-dna\pics\fupload) їfunction.move-uploaded-file]: failed to create stream: Permission denied in c:\inetpub\wwwroot\pc-dna\submit2.php on line 17
Warning: move_uploaded_file() їfunction.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\php2C.tmp' to 'C:\Inetpub\wwwroot\pc-dna\pics\fupload' in c:\inetpub\wwwroot\pc-dna\submit2.php on line 17
Couldn't copyThanks.