473,761 Members | 4,739 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

broken file upload

while(list($key ,$value) = each($_FILES["file"]["name"]))
{
if(!empty($valu e)){
$filename = $value;
$add = "upimg/$filename";
echo $_FILES["file"]["tmp_name"][$key];
$error=copy($_F ILES["file"]["tmp_name"][$key], $add);
if (!$error) $progressUpload ingPhotos=false ;
$error=chmod($a dd,0777);
if (!$error) $progressUpload ingPhotos=false ;
} else $progressUpload ingPhotos=false ;
}

the thing is that the file is never saved. any ideas?
Nov 1 '07 #1
6 2711
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($i d, $dir, $debug = false)
{
$ok = true;
$count = 0;

if (is_array($_FIL ES[$id]['error'])) {
// Multiple files

foreach ($_FILES[$id]['error'] as $key =$err) {
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_F ILE) {
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<br>";
}
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_F ILE) {
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<br>";
}
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('f ile', dirname(__FILE_ _) . '/uploads',
true);
echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
'.<br>';
}

?>

<h3>Single Upload</h3>

<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file"><br ><br>
<input type="submit" value=" OK ">
</p>
</form>

<h3>Multiple Uploads</h3>

<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br><br>
<input type="submit" value=" OK ">
</p>
</form>


On Nov 1, 3:27 am, Milan Krejci <r...@n0spam.ma il.czwrote:
while(list($key ,$value) = each($_FILES["file"]["name"]))
{
if(!empty($valu e)){
$filename = $value;
$add = "upimg/$filename";
echo $_FILES["file"]["tmp_name"][$key];
$error=copy($_F ILES["file"]["tmp_name"][$key], $add);
if (!$error) $progressUpload ingPhotos=false ;
$error=chmod($a dd,0777);
if (!$error) $progressUpload ingPhotos=false ;

} else $progressUpload ingPhotos=false ;
}

the thing is that the file is never saved. any ideas?

Nov 1 '07 #2

Warning: move_uploaded_f ile(/var/www/html/brides/inc/class/upimg/.cshrc)
[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_f ile() [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($i d, $dir, $debug = false)
{
$ok = true;
$count = 0;

if (is_array($_FIL ES[$id]['error'])) {
// Multiple files

foreach ($_FILES[$id]['error'] as $key =$err) {
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_F ILE) {
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<br>";
}
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_F ILE) {
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<br>";
}
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('f ile', dirname(__FILE_ _) . '/uploads',
true);
echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
'.<br>';
}

?>

<h3>Single Upload</h3>

<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file"><br ><br>
<input type="submit" value=" OK ">
</p>
</form>

<h3>Multiple Uploads</h3>

<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br><br>
<input type="submit" value=" OK ">
</p>
</form>


On Nov 1, 3:27 am, Milan Krejci <r...@n0spam.ma il.czwrote:
>while(list($ke y,$value) = each($_FILES["file"]["name"]))
{
if(!empty($val ue)){
$filename = $value;
$add = "upimg/$filename";
echo $_FILES["file"]["tmp_name"][$key];
$error=copy($_ FILES["file"]["tmp_name"][$key], $add);
if (!$error) $progressUpload ingPhotos=false ;
$error=chmod($ add,0777);
if (!$error) $progressUpload ingPhotos=false ;

} else $progressUpload ingPhotos=false ;
}

the thing is that the file is never saved. any ideas?

Nov 1 '07 #3
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 <r...@n0spam.ma il.czwrote:
Warning: move_uploaded_f ile(/var/www/html/brides/inc/class/upimg/.cshrc)
[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_f ile() [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($i d, $dir, $debug = false)
{
$ok = true;
$count = 0;
if (is_array($_FIL ES[$id]['error'])) {
// Multiple files
foreach ($_FILES[$id]['error'] as $key =$err) {
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_F ILE) {
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<br>";
}
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_F ILE) {
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<br>";
}
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('f ile', dirname(__FILE_ _) . '/uploads',
true);
echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
'.<br>';
}
?>
<h3>Single Upload</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file"><br ><br>
<input type="submit" value=" OK ">
</p>
</form>
<h3>Multiple Uploads</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br><br>
<input type="submit" value=" OK ">
</p>
</form>
On Nov 1, 3:27 am, Milan Krejci <r...@n0spam.ma il.czwrote:
while(list($key ,$value) = each($_FILES["file"]["name"]))
{
if(!empty($valu e)){
$filename = $value;
$add = "upimg/$filename";
echo $_FILES["file"]["tmp_name"][$key];
$error=copy($_F ILES["file"]["tmp_name"][$key], $add);
if (!$error) $progressUpload ingPhotos=false ;
$error=chmod($a dd,0777);
if (!$error) $progressUpload ingPhotos=false ;
} else $progressUpload ingPhotos=false ;
}
the thing is that the file is never saved. any ideas?

Nov 1 '07 #4
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 <r...@n0spam.ma il.czwrote:
>Warning: move_uploaded_f ile(/var/www/html/brides/inc/class/upimg/.cshrc)
[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_f ile() [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_reporti ng(E_ALL);
function storeUploads($i d, $dir, $debug = false)
{
$ok = true;
$count = 0;
if (is_array($_FIL ES[$id]['error'])) {
// Multiple files
foreach ($_FILES[$id]['error'] as $key =$err) {
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_F ILE) {
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<br>";
}
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_F ILE) {
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<br>";
}
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('f ile', dirname(__FILE_ _) . '/uploads',
true);
echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
'.<br>';
}
?>
<h3>Single Upload</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file"><br ><br>
<input type="submit" value=" OK ">
</p>
</form>
<h3>Multipl e Uploads</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br><br>
<input type="submit" value=" OK ">
</p>
</form>
On Nov 1, 3:27 am, Milan Krejci <r...@n0spam.ma il.czwrote:
while(list($ key,$value) = each($_FILES["file"]["name"]))
{
if(!empty($v alue)){
$filename = $value;
$add = "upimg/$filename";
echo $_FILES["file"]["tmp_name"][$key];
$error=copy( $_FILES["file"]["tmp_name"][$key], $add);
if (!$error) $progressUpload ingPhotos=false ;
$error=chmod ($add,0777);
if (!$error) $progressUpload ingPhotos=false ;
} else $progressUpload ingPhotos=false ;
}
the thing is that the file is never saved. any ideas?

Nov 1 '07 #5
Hmmmm. Are any other safe_mode features enabled perhaps...

On Nov 1, 7:58 am, Milan Krejci <r...@n0spam.ma il.czwrote:
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 <r...@n0spam.ma il.czwrote:
Warning: move_uploaded_f ile(/var/www/html/brides/inc/class/upimg/.cshrc)
[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_f ile() [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_reportin g(E_ALL);
function storeUploads($i d, $dir, $debug = false)
{
$ok = true;
$count = 0;
if (is_array($_FIL ES[$id]['error'])) {
// Multiple files
foreach ($_FILES[$id]['error'] as $key =$err) {
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_F ILE) {
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<br>";
}
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_F ILE) {
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<br>";
}
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('f ile', dirname(__FILE_ _) . '/uploads',
true);
echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
'.<br>';
}
?>
<h3>Single Upload</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file"><br ><br>
<input type="submit" value=" OK ">
</p>
</form>
<h3>Multiple Uploads</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br><br>
<input type="submit" value=" OK ">
</p>
</form>
On Nov 1, 3:27 am, Milan Krejci <r...@n0spam.ma il.czwrote:
while(list($k ey,$value) = each($_FILES["file"]["name"]))
{
if(!empty($va lue)){
$filename = $value;
$add = "upimg/$filename";
echo $_FILES["file"]["tmp_name"][$key];
$error=copy($ _FILES["file"]["tmp_name"][$key], $add);
if (!$error) $progressUpload ingPhotos=false ;
$error=chmod( $add,0777);
if (!$error) $progressUpload ingPhotos=false ;
} else $progressUpload ingPhotos=false ;
}
the thing is that the file is never saved. any ideas?

Nov 1 '07 #6
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 <r...@n0spam.ma il.czwrote:
>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_reporti ng(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 <r...@n0spam.ma il.czwrote:
Warning: move_uploaded_f ile(/var/www/html/brides/inc/class/upimg/.cshrc)
[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_f ile() [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_repor ting(E_ALL);
function storeUploads($i d, $dir, $debug = false)
{
$ok = true;
$count = 0;
if (is_array($_FIL ES[$id]['error'])) {
// Multiple files
foreach ($_FILES[$id]['error'] as $key =$err) {
if ($err != UPLOAD_ERR_OK && $err != UPLOAD_ERR_NO_F ILE) {
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<br>";
}
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_F ILE) {
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<br>";
}
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('f ile', dirname(__FILE_ _) . '/uploads',
true);
echo "Stored $count " . ($count == 1 ? 'file' : 'files') .
'.<br>';
}
?>
<h3>Singl e Upload</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file"><br ><br>
<input type="submit" value=" OK ">
</p>
</form>
<h3>Multipl e Uploads</h3>
<form action="upload. php" method="post" enctype="multip art/form-data">
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br>
<input type="file" name="file[]"><br><br>
<input type="submit" value=" OK ">
</p>
</form>
On Nov 1, 3:27 am, Milan Krejci <r...@n0spam.ma il.czwrote:
>while(list ($key,$value) = each($_FILES["file"]["name"]))
>{
>if(!empty( $value)){
>$filenam e = $value;
>$add = "upimg/$filename";
>echo $_FILES["file"]["tmp_name"][$key];
>$error=cop y($_FILES["file"]["tmp_name"][$key], $add);
>if (!$error) $progressUpload ingPhotos=false ;
>$error=chm od($add,0777);
>if (!$error) $progressUpload ingPhotos=false ;
>} else $progressUpload ingPhotos=false ;
>}
>the thing is that the file is never saved. any ideas?

Nov 1 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2938
by: Tihon | last post by:
Hello! I again need your help, just can't understand whats going on. Got this upload pictures form and it's having problem handling large files (~1.5 - 2 MB). Everything works fine if i just upload files, like this: copy ($myfile, $uploadfolder . "/" . $myfile_name); Everything works fine, it can process large files and everything, but i need to make sure that people only upload pictures, so i change
2
3930
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give them a caption, storing the caption and filename in a text file. It's a bit buggy when removing the photos and captions from the file, and also in displaying them on the delete page. you can see it in action at www.4am.com.au/gallery/upload.php...
13
4320
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
2
3436
by: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage() fileitem = form if fileitem.file: # It's an uploaded file; count lines
7
3190
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
2
7651
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but don't have any luck is to do a form validation. This script requires the files: db-file-to-disk.asp and _upload.asp. There is a DESCRIPTION field in the db-file-to-disk.asp file, what I want to do is the user has to field out this fied before...
1
5457
by: chrisj | last post by:
I'm using freeASPupload and got some assistance integrating to a Member script. It works successfully. In this modified version there are two groups that use this upload script. Members of one group get automatically re-directed after uploading. However, this member group never gets the benefit of knowing if they've uploaded an incorrect file size or incorrect file extension. Members from the second group do see the "exceeds max file...
6
3837
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the network should be able to connect to the database and run queries on the database or upload new music that does not yet exist on the database. The uploaded file's name should be in the following format: ARTIST - TITLE.mp3. I have the code to upload images,...
7
7156
Curtis Rutland
by: Curtis Rutland | last post by:
Building A Silverlight (2.0) Multi-File Uploader All source code is C#. VB.NET source is coming soon. Note: This project requires Visual Studio 2008 SP1 or Visual Web Developer 2008 SP1 and Silverlight 2.0. To get these tools please visit this page Get Started : The Official Microsoft Silverlight Site and follow Step 1. Occasionally you find the need to have users upload multiple files at once. You could use multiple FileUpload...
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.