NYCPHP Meetup

NYPHP.org

[nycphp-talk] Files are not uploading on Windows 2003 sever using PHP code

Jeremy McEntire j.andrew.mcentire at gmail.com
Sun Aug 5 12:43:22 EDT 2007


> I have installed Windows 2003 sever and then installed PHP 4.3.4 on it.
> I have a problem that file is not uploading to the specified directory on
> the server ( locally windows 2003 ). I am using the file upload code in php
> like :

> <? if ($_FILES['filefield']['name'] != ""){

> @copy($_FILES['filefield']['tmp_name'],"../dir1/".$_FILES['filefield'
> ]['name']);

> }
> ?>

You might check out:
http://us.php.net/manual/en/features.file-upload.php

It looks like their directory is an absolute path.  I don't know how
that might work in a chrooted environment, but I don't think your
'../dir1' makes sense if it is expecting an absolute path.  The copy
doc doesn't state explicitly.  But, it's probably better to use the
uploaded file functions -- copy doesn't save you anything as the temp
file ought to be automatically deleted at the end of the script
anyway.

Here's my suggestion:

<?php

if ( isset( $FILES['userfile']['tmp_name'] ) && is_uploaded_file(
$FILES['userfile']['tmp_name'] ) ) {
    move_uploaded_file( $FILES['userfile']['tmp_name'], $dir .
$FILES['userfile']['name'] );
}

?>

Good luck,
Jeremy



More information about the talk mailing list