broken file upload
am 01.11.2007 09:27:12 von Milan Krejci
while(list($key,$value) = each($_FILES["file"]["name"]))
{
if(!empty($value)){
$filename = $value;
$add = "upimg/$filename";
echo $_FILES["file"]["tmp_name"][$key];
$error=copy($_FILES["file"]["tmp_name"][$key], $add);
if (!$error) $progressUploadingPhotos=false;
$error=chmod($add,0777);
if (!$error) $progressUploadingPhotos=false;
} else $progressUploadingPhotos=false;
}
the thing is that the file is never saved. any ideas?
Re: broken file upload
am 01.11.2007 11:58:58 von petersprc
One thing to check is if error_reporting(E_ALL | E_STRICT) gives any
notices. The php script below shows how to handle multiple and single
file uploads.
[upload.php]
// This page will store the uploaded files in a directory
// called "uploads".
error_reporting(E_ALL);
function storeUploads($id, $dir, $debug = false)
{
$ok = true;
$count = 0;
if (is_array($_FILES[$id]['error'])) {
// Multiple files
foreach ($_FILES[$id]['error'] as $key => $err) {
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
trigger_error("Upload of file $id failed with error " .
"code $err.", E_USER_ERROR);
$ok = false;
} elseif ($err == UPLOAD_ERR_OK) {
$tmp = $_FILES[$id]['tmp_name'][$key];
$name = $_FILES[$id]['name'][$key];
$dest = "$dir/" . basename($name);
if ($debug) {
echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
"dest = $dest
";
}
if (!move_uploaded_file($tmp, $dest)) {
trigger_error("Failed to save file to $dest",
E_USER_ERROR);
$ok = false;
} else {
$count++;
}
}
}
} else {
// Single file
$err = $_FILES[$id]['error'];
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
trigger_error("Upload of file $id failed with error code " .
"$err.", E_USER_ERROR);
$ok = false;
} elseif ($err == UPLOAD_ERR_OK) {
$tmp = $_FILES[$id]['tmp_name'];
$name = $_FILES[$id]['name'];
$dest = "$dir/" . basename($name);
if ($debug) {
echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
"dest = $dest
";
}
if (!move_uploaded_file($tmp, $dest)) {
trigger_error("Failed to save file to $dest",
E_USER_ERROR);
$ok = false;
} else {
$count++;
}
}
}
return $ok ? $count : $ok;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$count = storeUploads('file', dirname(__FILE__) . '/uploads',
true);
echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
'.
';
}
?>
Single Upload
Multiple Uploads
On Nov 1, 3:27 am, Milan Krejci wrote:
> while(list($key,$value) = each($_FILES["file"]["name"]))
> {
> if(!empty($value)){
> $filename = $value;
> $add = "upimg/$filename";
> echo $_FILES["file"]["tmp_name"][$key];
> $error=copy($_FILES["file"]["tmp_name"][$key], $add);
> if (!$error) $progressUploadingPhotos=false;
> $error=chmod($add,0777);
> if (!$error) $progressUploadingPhotos=false;
>
> } else $progressUploadingPhotos=false;
> }
>
> the thing is that the file is never saved. any ideas?
Re: broken file upload
am 01.11.2007 12:12:12 von Milan Krejci
Warning: move_uploaded_file(/var/www/html/brides/inc/class/upimg/.csh rc)
[function.move-uploaded-file]: failed to open stream: isn't neither a
file nor directory in /var/www/html/brides/inc/class/register.php on
line 101
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
move '/tmp/php6WsSrx' to '/var/www/html/brides/inc/class/upimg/.cshrc'
in /var/www/html/brides/inc/class/register.php on line 101
Fatal error: Failed to save file to
/var/www/html/brides/inc/class/upimg/.cshrc in
/var/www/html/brides/inc/class/register.php on line 103
petersprc napsal(a):
> One thing to check is if error_reporting(E_ALL | E_STRICT) gives any
> notices. The php script below shows how to handle multiple and single
> file uploads.
>
> [upload.php]
>
>
> // This page will store the uploaded files in a directory
> // called "uploads".
>
> error_reporting(E_ALL);
>
> function storeUploads($id, $dir, $debug = false)
> {
> $ok = true;
> $count = 0;
>
> if (is_array($_FILES[$id]['error'])) {
> // Multiple files
>
> foreach ($_FILES[$id]['error'] as $key => $err) {
> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
> trigger_error("Upload of file $id failed with error " .
> "code $err.", E_USER_ERROR);
> $ok = false;
> } elseif ($err == UPLOAD_ERR_OK) {
> $tmp = $_FILES[$id]['tmp_name'][$key];
> $name = $_FILES[$id]['name'][$key];
> $dest = "$dir/" . basename($name);
> if ($debug) {
> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
> "dest = $dest
";
> }
> if (!move_uploaded_file($tmp, $dest)) {
> trigger_error("Failed to save file to $dest",
> E_USER_ERROR);
> $ok = false;
> } else {
> $count++;
> }
> }
> }
> } else {
> // Single file
>
> $err = $_FILES[$id]['error'];
> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
> trigger_error("Upload of file $id failed with error code " .
> "$err.", E_USER_ERROR);
> $ok = false;
> } elseif ($err == UPLOAD_ERR_OK) {
> $tmp = $_FILES[$id]['tmp_name'];
> $name = $_FILES[$id]['name'];
> $dest = "$dir/" . basename($name);
> if ($debug) {
> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
> "dest = $dest
";
> }
> if (!move_uploaded_file($tmp, $dest)) {
> trigger_error("Failed to save file to $dest",
> E_USER_ERROR);
> $ok = false;
> } else {
> $count++;
> }
> }
> }
>
> return $ok ? $count : $ok;
> }
>
> if ($_SERVER['REQUEST_METHOD'] == 'POST') {
> $count = storeUploads('file', dirname(__FILE__) . '/uploads',
> true);
> echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
> '.
';
> }
>
> ?>
>
>
Single Upload
>
>
>
> Multiple Uploads
>
>
>
>
>
>
> On Nov 1, 3:27 am, Milan Krejci wrote:
>> while(list($key,$value) = each($_FILES["file"]["name"]))
>> {
>> if(!empty($value)){
>> $filename = $value;
>> $add = "upimg/$filename";
>> echo $_FILES["file"]["tmp_name"][$key];
>> $error=copy($_FILES["file"]["tmp_name"][$key], $add);
>> if (!$error) $progressUploadingPhotos=false;
>> $error=chmod($add,0777);
>> if (!$error) $progressUploadingPhotos=false;
>>
>> } else $progressUploadingPhotos=false;
>> }
>>
>> the thing is that the file is never saved. any ideas?
>
>
Re: broken file upload
am 01.11.2007 13:45:53 von petersprc
Hmm, does upimg exist and is writable by php? You can check directly
by doing:
error_reporting(E_ALL);
touch('/var/www/html/brides/inc/class/upimg/.cshrc');
Might want to check if open_basedir is defined also.
On Nov 1, 6:12 am, Milan Krejci wrote:
> Warning: move_uploaded_file(/var/www/html/brides/inc/class/upimg/.csh rc)
> [function.move-uploaded-file]: failed to open stream: isn't neither a
> file nor directory in /var/www/html/brides/inc/class/register.php on
> line 101
>
> Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
> move '/tmp/php6WsSrx' to '/var/www/html/brides/inc/class/upimg/.cshrc'
> in /var/www/html/brides/inc/class/register.php on line 101
>
> Fatal error: Failed to save file to
> /var/www/html/brides/inc/class/upimg/.cshrc in
> /var/www/html/brides/inc/class/register.php on line 103
>
> petersprc napsal(a):
>
> > One thing to check is if error_reporting(E_ALL | E_STRICT) gives any
> > notices. The php script below shows how to handle multiple and single
> > file uploads.
>
> > [upload.php]
> >
>
> > // This page will store the uploaded files in a directory
> > // called "uploads".
>
> > error_reporting(E_ALL);
>
> > function storeUploads($id, $dir, $debug = false)
> > {
> > $ok = true;
> > $count = 0;
>
> > if (is_array($_FILES[$id]['error'])) {
> > // Multiple files
>
> > foreach ($_FILES[$id]['error'] as $key => $err) {
> > if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
> > trigger_error("Upload of file $id failed with error " .
> > "code $err.", E_USER_ERROR);
> > $ok = false;
> > } elseif ($err == UPLOAD_ERR_OK) {
> > $tmp = $_FILES[$id]['tmp_name'][$key];
> > $name = $_FILES[$id]['name'][$key];
> > $dest = "$dir/" . basename($name);
> > if ($debug) {
> > echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
> > "dest = $dest
";
> > }
> > if (!move_uploaded_file($tmp, $dest)) {
> > trigger_error("Failed to save file to $dest",
> > E_USER_ERROR);
> > $ok = false;
> > } else {
> > $count++;
> > }
> > }
> > }
> > } else {
> > // Single file
>
> > $err = $_FILES[$id]['error'];
> > if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
> > trigger_error("Upload of file $id failed with error code " .
> > "$err.", E_USER_ERROR);
> > $ok = false;
> > } elseif ($err == UPLOAD_ERR_OK) {
> > $tmp = $_FILES[$id]['tmp_name'];
> > $name = $_FILES[$id]['name'];
> > $dest = "$dir/" . basename($name);
> > if ($debug) {
> > echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
> > "dest = $dest
";
> > }
> > if (!move_uploaded_file($tmp, $dest)) {
> > trigger_error("Failed to save file to $dest",
> > E_USER_ERROR);
> > $ok = false;
> > } else {
> > $count++;
> > }
> > }
> > }
>
> > return $ok ? $count : $ok;
> > }
>
> > if ($_SERVER['REQUEST_METHOD'] == 'POST') {
> > $count = storeUploads('file', dirname(__FILE__) . '/uploads',
> > true);
> > echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
> > '.
';
> > }
>
> > ?>
>
> > Single Upload
>
> >
> >
>
> > Multiple Uploads
>
> >
>
> > On Nov 1, 3:27 am, Milan Krejci wrote:
> >> while(list($key,$value) = each($_FILES["file"]["name"]))
> >> {
> >> if(!empty($value)){
> >> $filename = $value;
> >> $add = "upimg/$filename";
> >> echo $_FILES["file"]["tmp_name"][$key];
> >> $error=copy($_FILES["file"]["tmp_name"][$key], $add);
> >> if (!$error) $progressUploadingPhotos=false;
> >> $error=chmod($add,0777);
> >> if (!$error) $progressUploadingPhotos=false;
>
> >> } else $progressUploadingPhotos=false;
> >> }
>
> >> the thing is that the file is never saved. any ideas?
Re: broken file upload
am 01.11.2007 13:58:56 von Milan Krejci
open_basedir no value no value
the directory indeed exists and is writable by apache, root or whoever
petersprc napsal(a):
> Hmm, does upimg exist and is writable by php? You can check directly
> by doing:
>
> error_reporting(E_ALL);
> touch('/var/www/html/brides/inc/class/upimg/.cshrc');
>
> Might want to check if open_basedir is defined also.
>
> On Nov 1, 6:12 am, Milan Krejci wrote:
>> Warning: move_uploaded_file(/var/www/html/brides/inc/class/upimg/.csh rc)
>> [function.move-uploaded-file]: failed to open stream: isn't neither a
>> file nor directory in /var/www/html/brides/inc/class/register.php on
>> line 101
>>
>> Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
>> move '/tmp/php6WsSrx' to '/var/www/html/brides/inc/class/upimg/.cshrc'
>> in /var/www/html/brides/inc/class/register.php on line 101
>>
>> Fatal error: Failed to save file to
>> /var/www/html/brides/inc/class/upimg/.cshrc in
>> /var/www/html/brides/inc/class/register.php on line 103
>>
>> petersprc napsal(a):
>>
>>> One thing to check is if error_reporting(E_ALL | E_STRICT) gives any
>>> notices. The php script below shows how to handle multiple and single
>>> file uploads.
>>> [upload.php]
>>>
>>> // This page will store the uploaded files in a directory
>>> // called "uploads".
>>> error_reporting(E_ALL);
>>> function storeUploads($id, $dir, $debug = false)
>>> {
>>> $ok = true;
>>> $count = 0;
>>> if (is_array($_FILES[$id]['error'])) {
>>> // Multiple files
>>> foreach ($_FILES[$id]['error'] as $key => $err) {
>>> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
>>> trigger_error("Upload of file $id failed with error " .
>>> "code $err.", E_USER_ERROR);
>>> $ok = false;
>>> } elseif ($err == UPLOAD_ERR_OK) {
>>> $tmp = $_FILES[$id]['tmp_name'][$key];
>>> $name = $_FILES[$id]['name'][$key];
>>> $dest = "$dir/" . basename($name);
>>> if ($debug) {
>>> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
>>> "dest = $dest
";
>>> }
>>> if (!move_uploaded_file($tmp, $dest)) {
>>> trigger_error("Failed to save file to $dest",
>>> E_USER_ERROR);
>>> $ok = false;
>>> } else {
>>> $count++;
>>> }
>>> }
>>> }
>>> } else {
>>> // Single file
>>> $err = $_FILES[$id]['error'];
>>> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
>>> trigger_error("Upload of file $id failed with error code " .
>>> "$err.", E_USER_ERROR);
>>> $ok = false;
>>> } elseif ($err == UPLOAD_ERR_OK) {
>>> $tmp = $_FILES[$id]['tmp_name'];
>>> $name = $_FILES[$id]['name'];
>>> $dest = "$dir/" . basename($name);
>>> if ($debug) {
>>> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
>>> "dest = $dest
";
>>> }
>>> if (!move_uploaded_file($tmp, $dest)) {
>>> trigger_error("Failed to save file to $dest",
>>> E_USER_ERROR);
>>> $ok = false;
>>> } else {
>>> $count++;
>>> }
>>> }
>>> }
>>> return $ok ? $count : $ok;
>>> }
>>> if ($_SERVER['REQUEST_METHOD'] == 'POST') {
>>> $count = storeUploads('file', dirname(__FILE__) . '/uploads',
>>> true);
>>> echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
>>> '.
';
>>> }
>>> ?>
>>> Single Upload
>>>
>>>
>>> Multiple Uploads
>>>
>>> On Nov 1, 3:27 am, Milan Krejci wrote:
>>>> while(list($key,$value) = each($_FILES["file"]["name"]))
>>>> {
>>>> if(!empty($value)){
>>>> $filename = $value;
>>>> $add = "upimg/$filename";
>>>> echo $_FILES["file"]["tmp_name"][$key];
>>>> $error=copy($_FILES["file"]["tmp_name"][$key], $add);
>>>> if (!$error) $progressUploadingPhotos=false;
>>>> $error=chmod($add,0777);
>>>> if (!$error) $progressUploadingPhotos=false;
>>>> } else $progressUploadingPhotos=false;
>>>> }
>>>> the thing is that the file is never saved. any ideas?
>
>
Re: broken file upload
am 01.11.2007 14:23:19 von petersprc
Hmmmm. Are any other safe_mode features enabled perhaps...
On Nov 1, 7:58 am, Milan Krejci wrote:
> open_basedir no value no value
>
> the directory indeed exists and is writable by apache, root or whoever
>
> petersprc napsal(a):
>
> > Hmm, does upimg exist and is writable by php? You can check directly
> > by doing:
>
> > error_reporting(E_ALL);
> > touch('/var/www/html/brides/inc/class/upimg/.cshrc');
>
> > Might want to check if open_basedir is defined also.
>
> > On Nov 1, 6:12 am, Milan Krejci wrote:
> >> Warning: move_uploaded_file(/var/www/html/brides/inc/class/upimg/.csh rc)
> >> [function.move-uploaded-file]: failed to open stream: isn't neither a
> >> file nor directory in /var/www/html/brides/inc/class/register.php on
> >> line 101
>
> >> Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
> >> move '/tmp/php6WsSrx' to '/var/www/html/brides/inc/class/upimg/.cshrc'
> >> in /var/www/html/brides/inc/class/register.php on line 101
>
> >> Fatal error: Failed to save file to
> >> /var/www/html/brides/inc/class/upimg/.cshrc in
> >> /var/www/html/brides/inc/class/register.php on line 103
>
> >> petersprc napsal(a):
>
> >>> One thing to check is if error_reporting(E_ALL | E_STRICT) gives any
> >>> notices. The php script below shows how to handle multiple and single
> >>> file uploads.
> >>> [upload.php]
> >>>
> >>> // This page will store the uploaded files in a directory
> >>> // called "uploads".
> >>> error_reporting(E_ALL);
> >>> function storeUploads($id, $dir, $debug = false)
> >>> {
> >>> $ok = true;
> >>> $count = 0;
> >>> if (is_array($_FILES[$id]['error'])) {
> >>> // Multiple files
> >>> foreach ($_FILES[$id]['error'] as $key => $err) {
> >>> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
> >>> trigger_error("Upload of file $id failed with error " .
> >>> "code $err.", E_USER_ERROR);
> >>> $ok = false;
> >>> } elseif ($err == UPLOAD_ERR_OK) {
> >>> $tmp = $_FILES[$id]['tmp_name'][$key];
> >>> $name = $_FILES[$id]['name'][$key];
> >>> $dest = "$dir/" . basename($name);
> >>> if ($debug) {
> >>> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
> >>> "dest = $dest
";
> >>> }
> >>> if (!move_uploaded_file($tmp, $dest)) {
> >>> trigger_error("Failed to save file to $dest",
> >>> E_USER_ERROR);
> >>> $ok = false;
> >>> } else {
> >>> $count++;
> >>> }
> >>> }
> >>> }
> >>> } else {
> >>> // Single file
> >>> $err = $_FILES[$id]['error'];
> >>> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
> >>> trigger_error("Upload of file $id failed with error code " .
> >>> "$err.", E_USER_ERROR);
> >>> $ok = false;
> >>> } elseif ($err == UPLOAD_ERR_OK) {
> >>> $tmp = $_FILES[$id]['tmp_name'];
> >>> $name = $_FILES[$id]['name'];
> >>> $dest = "$dir/" . basename($name);
> >>> if ($debug) {
> >>> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
> >>> "dest = $dest
";
> >>> }
> >>> if (!move_uploaded_file($tmp, $dest)) {
> >>> trigger_error("Failed to save file to $dest",
> >>> E_USER_ERROR);
> >>> $ok = false;
> >>> } else {
> >>> $count++;
> >>> }
> >>> }
> >>> }
> >>> return $ok ? $count : $ok;
> >>> }
> >>> if ($_SERVER['REQUEST_METHOD'] == 'POST') {
> >>> $count = storeUploads('file', dirname(__FILE__) . '/uploads',
> >>> true);
> >>> echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
> >>> '.
';
> >>> }
> >>> ?>
> >>> Single Upload
> >>>
> >>>
> >>> Multiple Uploads
> >>>
> >>> On Nov 1, 3:27 am, Milan Krejci wrote:
> >>>> while(list($key,$value) = each($_FILES["file"]["name"]))
> >>>> {
> >>>> if(!empty($value)){
> >>>> $filename = $value;
> >>>> $add = "upimg/$filename";
> >>>> echo $_FILES["file"]["tmp_name"][$key];
> >>>> $error=copy($_FILES["file"]["tmp_name"][$key], $add);
> >>>> if (!$error) $progressUploadingPhotos=false;
> >>>> $error=chmod($add,0777);
> >>>> if (!$error) $progressUploadingPhotos=false;
> >>>> } else $progressUploadingPhotos=false;
> >>>> }
> >>>> the thing is that the file is never saved. any ideas?
Re: broken file upload
am 01.11.2007 14:28:13 von Milan Krejci
nope, safe_mode is off
petersprc napsal(a):
> Hmmmm. Are any other safe_mode features enabled perhaps...
>
> On Nov 1, 7:58 am, Milan Krejci wrote:
>> open_basedir no value no value
>>
>> the directory indeed exists and is writable by apache, root or whoever
>>
>> petersprc napsal(a):
>>
>>> Hmm, does upimg exist and is writable by php? You can check directly
>>> by doing:
>>> error_reporting(E_ALL);
>>> touch('/var/www/html/brides/inc/class/upimg/.cshrc');
>>> Might want to check if open_basedir is defined also.
>>> On Nov 1, 6:12 am, Milan Krejci wrote:
>>>> Warning: move_uploaded_file(/var/www/html/brides/inc/class/upimg/.csh rc)
>>>> [function.move-uploaded-file]: failed to open stream: isn't neither a
>>>> file nor directory in /var/www/html/brides/inc/class/register.php on
>>>> line 101
>>>> Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to
>>>> move '/tmp/php6WsSrx' to '/var/www/html/brides/inc/class/upimg/.cshrc'
>>>> in /var/www/html/brides/inc/class/register.php on line 101
>>>> Fatal error: Failed to save file to
>>>> /var/www/html/brides/inc/class/upimg/.cshrc in
>>>> /var/www/html/brides/inc/class/register.php on line 103
>>>> petersprc napsal(a):
>>>>> One thing to check is if error_reporting(E_ALL | E_STRICT) gives any
>>>>> notices. The php script below shows how to handle multiple and single
>>>>> file uploads.
>>>>> [upload.php]
>>>>>
>>>>> // This page will store the uploaded files in a directory
>>>>> // called "uploads".
>>>>> error_reporting(E_ALL);
>>>>> function storeUploads($id, $dir, $debug = false)
>>>>> {
>>>>> $ok = true;
>>>>> $count = 0;
>>>>> if (is_array($_FILES[$id]['error'])) {
>>>>> // Multiple files
>>>>> foreach ($_FILES[$id]['error'] as $key => $err) {
>>>>> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
>>>>> trigger_error("Upload of file $id failed with error " .
>>>>> "code $err.", E_USER_ERROR);
>>>>> $ok = false;
>>>>> } elseif ($err == UPLOAD_ERR_OK) {
>>>>> $tmp = $_FILES[$id]['tmp_name'][$key];
>>>>> $name = $_FILES[$id]['name'][$key];
>>>>> $dest = "$dir/" . basename($name);
>>>>> if ($debug) {
>>>>> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
>>>>> "dest = $dest
";
>>>>> }
>>>>> if (!move_uploaded_file($tmp, $dest)) {
>>>>> trigger_error("Failed to save file to $dest",
>>>>> E_USER_ERROR);
>>>>> $ok = false;
>>>>> } else {
>>>>> $count++;
>>>>> }
>>>>> }
>>>>> }
>>>>> } else {
>>>>> // Single file
>>>>> $err = $_FILES[$id]['error'];
>>>>> if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_FILE) {
>>>>> trigger_error("Upload of file $id failed with error code " .
>>>>> "$err.", E_USER_ERROR);
>>>>> $ok = false;
>>>>> } elseif ($err == UPLOAD_ERR_OK) {
>>>>> $tmp = $_FILES[$id]['tmp_name'];
>>>>> $name = $_FILES[$id]['name'];
>>>>> $dest = "$dir/" . basename($name);
>>>>> if ($debug) {
>>>>> echo "Storing file: id = $id, tmp = $tmp, name = $name, " .
>>>>> "dest = $dest
";
>>>>> }
>>>>> if (!move_uploaded_file($tmp, $dest)) {
>>>>> trigger_error("Failed to save file to $dest",
>>>>> E_USER_ERROR);
>>>>> $ok = false;
>>>>> } else {
>>>>> $count++;
>>>>> }
>>>>> }
>>>>> }
>>>>> return $ok ? $count : $ok;
>>>>> }
>>>>> if ($_SERVER['REQUEST_METHOD'] == 'POST') {
>>>>> $count = storeUploads('file', dirname(__FILE__) . '/uploads',
>>>>> true);
>>>>> echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
>>>>> '.
';
>>>>> }
>>>>> ?>
>>>>> Single Upload
>>>>>
>>>>>
>>>>> Multiple Uploads
>>>>>
>>>>> On Nov 1, 3:27 am, Milan Krejci wrote:
>>>>>> while(list($key,$value) = each($_FILES["file"]["name"]))
>>>>>> {
>>>>>> if(!empty($value)){
>>>>>> $filename = $value;
>>>>>> $add = "upimg/$filename";
>>>>>> echo $_FILES["file"]["tmp_name"][$key];
>>>>>> $error=copy($_FILES["file"]["tmp_name"][$key], $add);
>>>>>> if (!$error) $progressUploadingPhotos=false;
>>>>>> $error=chmod($add,0777);
>>>>>> if (!$error) $progressUploadingPhotos=false;
>>>>>> } else $progressUploadingPhotos=false;
>>>>>> }
>>>>>> the thing is that the file is never saved. any ideas?
>
>