Problems uploading files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Prismax
Forum Newbie
Posts: 2
Joined: Wed Apr 05, 2006 7:50 am

Problems uploading files

Post by Prismax »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

I have this weird problem with uploading some files.

I use a HTML-form, with the following input somewhere :

Code: Select all

<tr><td>Banner:</td><td><input type="file" name="newbanner" size="40"></td></tr>
The form tag is like :

Code: Select all

<form action="updateaction.php" enctype="multipart/form-data" method="post">
When i look at updateaction.php I have the following code :

Code: Select all

if ((is_uploaded_file($_FILES['newbanner']['tmp_name'])) and (strlen($_FILES['newbanner']['name']) > 0)){
	move_uploaded_file($_FILES['newbanner']['tmp_name'],'../../brand/'.$_FILES['newbanner']['name']);
}
However it doesn't work. Even weirder : when I do a

Code: Select all

echo $_FILES['newbanner']['name']
I get nothing (string length also is zero). Does anyone have any idea why this is?


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
ed209
Forum Contributor
Posts: 153
Joined: Thu May 12, 2005 5:06 am
Location: UK

Post by ed209 »

what happens when you:

Code: Select all

print_r($_FILES);
also, have you changed the permissions on 'brand/' ?
audz
Forum Newbie
Posts: 2
Joined: Wed Apr 05, 2006 12:21 pm

Empty $_FILES

Post by audz »

Hi,

I am new to PHP so please bear with me. :)

I have the same problem. I tried print_r($_FILES) but its empty. What could be the cause of this?

I would appreciate any help!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: Empty $_FILES

Post by feyd »

audz wrote:Hi,

I am new to PHP so please bear with me. :)

I have the same problem. I tried print_r($_FILES) but its empty. What could be the cause of this?

I would appreciate any help!
an empty $_FILES means nothing was submitted that was a file upload field.
audz
Forum Newbie
Posts: 2
Joined: Wed Apr 05, 2006 12:21 pm

Empty?

Post by audz »

Why would it be empty?
Prismax
Forum Newbie
Posts: 2
Joined: Wed Apr 05, 2006 7:50 am

Post by Prismax »

First of all, I'm very sorry to the moderators. I didn't notice the PHP tag, only the Code tag, but I'll make sure I'll do it right in the future.

I tried the print_r($_FILES) but it was empty. As you can see in my code I use the appropriate HTML input parameters....

I still haven't been able to solve this one....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

where in the HTML does the <form> tag lie? Are you running a DOCTYPE in the page?
Post Reply