Weird uploading problem

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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Weird uploading problem

Post by John Cartwright »

Hi, I use an uploading class to handle all my images, resizing, thumbnails etc but one day out of the blue this would not work properly. I can't really explain it since I never touched any server configurations or code, neither did my host.

Anyways, the code fails at

Code: Select all

if(!file_exists($_FILES[$this->field_name]['tmp_name']))
			{
				return $this->error(1);
			}
even though when printing out $_FILES I get


Code: Select all

їmoneyshot] => Array
        (
            їname] => illusion.jpg
            їtype] => image/pjpeg
            їtmp_name] => /var/tmp/phpV9dQ92
            їerror] => 0
            їsize] => 27422
        )
$this->field_name is moneyshot if your wondering. Anyone shed some light on this? It's been a rough few days :roll:
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Obviously, the file is not existing. Can you output the contents of the temporary directory right before the snippet?
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

maybe they goofed the chmodding of everything? Something similar happened to me recently when, out of the blue, one of my hosts up and chmodded every single file to 644 or something. -_-'
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

or maybe the tmp folder is full.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Not sure what you mean? I know its probably a path issue, but am sort of stumped as to why it suddenly stopped working.. I know I can read the temporary directly because the file is going somewhere..

Also chmod's are all fine.. help :oops:
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

hongco wrote:or maybe the tmp folder is full.
Temporary folders are constantly being deleted by apache .. arn't they? Should not be a problem.

Sorry I forgot to mention that I am using apache 1.3, with php 4.3.2
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

not exactly. I have read posts posted by server owner complaining about temp folder being full. I could be wrong, but that's what they said.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

maybe try "hard coding" one outside of your class and see if it works. If it does then you know it's an issue within your class...if not then you've narrowed down the prob.

does it do with all files (any size, type etc).
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I don't really understand what you mean, because if the file never exists, how am I going to do anything with it? Also, yes the file type does not affect things, nor does filesize.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Jcart wrote:I don't really understand what you mean, because if the file never exists, how am I going to do anything with it? Also, yes the file type does not affect things, nor does filesize.
I'm just suggesting that you create the upload script on a new page (outside of your class) and try uploading again... just to ensure it's not something else in your class that's causing the explosion.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

if ( move_uploaded_file($_FILES['userfile']['tmp_name'],'images/'.$_FILES['userfile']['name']))
    echo "success!";
  else
	echo "fail!";
That snipplet works fine, can anyone suggest why I am unable to detect the uploaded file in the temp dir?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Not sure, but i dont think you are able to get whtvr is in the tmp dir

try

Code: Select all

$tmp_name = $_FILES[$file_name]['tmp_name'] #without obj
if(!file_exists($tmp_name))
{
  return $this->error(1);
}
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Then how do you explain my quick test? (my last post). I am able to read the temp file fine. :cry:
Post Reply