469,336 Members | 6,145 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

File upload not working but no error...

Hello,

I have a file upload page, and I've had it working fine, it was
beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
work now.

The file name is correct, the directory where it's going on the
server is correct (checked through prints etc.). I've changed the dir
to 777 (is that right?) and this is what I get on the
print_r($_FILES); line:

Array
(
[userfile] => Array
(
[name] => amy.txt
[type] => text/plain
[tmp_name] => /tmp/phpccPHUE
[error] => 0
[size] => 39
)

)

And the file is not uploading - I'm getting an error on the line:

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
And yet, you'll notice the line above clearly states I get '0'
error?!?!

I can't work it this one out... any helpful hints? Please?

Many many thanks,

Amy
Jul 17 '05 #1
3 6895
Amy Kimber wrote:
Hello,

I have a file upload page, and I've had it working fine, it was
beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
work now.

The file name is correct, the directory where it's going on the
server is correct (checked through prints etc.). I've changed the dir
to 777 (is that right?) and this is what I get on the
print_r($_FILES); line:

Array
(
[userfile] => Array
(
[name] => amy.txt
[type] => text/plain
[tmp_name] => /tmp/phpccPHUE
[error] => 0
[size] => 39
)

)

And the file is not uploading - I'm getting an error on the line:

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))

<snip>

What is the value of $uploadfile?
Jul 17 '05 #2

"Agelmar" <if**********@comcast.net> wrote in message
news:c4*************@ID-30799.news.uni-berlin.de...
Amy Kimber wrote:
Hello,

I have a file upload page, and I've had it working fine, it was
beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
work now.

The file name is correct, the directory where it's going on the
server is correct (checked through prints etc.). I've changed the dir
to 777 (is that right?) and this is what I get on the
print_r($_FILES); line:

Array
(
[userfile] => Array
(
[name] => amy.txt
[type] => text/plain
[tmp_name] => /tmp/phpccPHUE
[error] => 0
[size] => 39
)

)

And the file is not uploading - I'm getting an error on the line:

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))

<snip>

What is the value of $uploadfile?


And what is the error?
Jul 17 '05 #3
"Chung Leong" <ch***********@hotmail.com> wrote in message news:<ef********************@comcast.com>...
"Agelmar" <if**********@comcast.net> wrote in message
news:c4*************@ID-30799.news.uni-berlin.de...
Amy Kimber wrote:
Hello,

I have a file upload page, and I've had it working fine, it was
beautiful :-) Anyway, the powers that be moved hosts... and it doesn't
work now.

The file name is correct, the directory where it's going on the
server is correct (checked through prints etc.). I've changed the dir
to 777 (is that right?) and this is what I get on the
print_r($_FILES); line:

Array
(
[userfile] => Array
(
[name] => index.html
[type] => text/plain
[tmp_name] => /tmp/phpccPHUE
[error] => 0
[size] => 39
)

)

And the file is not uploading - I'm getting an error on the line:

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) <snip>

What is the value of $uploadfile?

$uploadfile = $uploaddir . $_FILES['userfile']['name'];

which comes out as...

/web/demo/translation/index.html

which seems correct,
And what is the error?


that's just hte point, [error] => 0 - but the line that's throwing the
error is:

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{

I have had this code working before on another server, so what am I
doing wrong? Please! Any comments at all would be useful!

:-)

Many thanks,

Amy
here's the whole code

---------------------

<?php

session_start();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>File upload</title>

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />

</head>

<?php

// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used
instead

// of $_FILES. In PHP versions earlier than 4.0.3, use copy() and

// is_uploaded_file() instead of move_uploaded_file.
$uploaddir = '/web/demo/translation/';

$uploadfile = $uploaddir . $_FILES['userfile']['name'];

print ($uploadfile);
print ($_FILES['userfile']['name']);
print "<pre>";
print_r($_FILES);
print ("name: " . $uploadfile);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{

$msg = "File (" . $_FILES['userfile']['name'] . ") is valid, and
was successfully uploaded. ";

//print_r($_FILES);
$jobid = time();
$rename = $jobid . $_FILES['userfile']['name']; //or $rename =
$username;
$file_name = $_FILES['userfile']['name'];
$read_extension = explode(".", $file_name);
$ext = $read_extension[1];
//$rename = $rename.".".$ext;
rename($file_name, $rename);
$info = array($rename, $_FILES['userfile']['type']);
session_register('info');
session_start();
} else {
$msg = "File did not upload successfully, close window and try
againn";
$msg = $msg . print_r($_FILES);
}

?>

<BODY bgColor=#ffffff >
etc. etc.

----------------------

and the output is this:

------------

/web/demo/translation/index.html
index.html
Array
(
[userfile] => Array
(
[name] => index.html
[type] => text/html
[tmp_name] => /tmp/phpEyvvil
[error] => 0
[size] => 477
)

)
name: /web/demo/translation/index.html

Array
(
[userfile] => Array
(
[name] => index.html
[type] => text/html
[tmp_name] => /tmp/phpEyvvil
[error] => 0
[size] => 477
)

)
Upload File File did not upload successfully, close window and try
againn1
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by mpar612 | last post: by
1 post views Thread by igotyourdotnet | last post: by
Jacotheron
6 posts views Thread by Jacotheron | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.