Jump to content

Recommended Posts

Hi all!

I'm going through a very strange problem.

I have an identical code on BlueHost and GoDaddy.

On BlueHost it does NOT work and on GoDaddy it works just fine.

Both BlueHost and GoDaddy are using PHP v5.2.17

The code is:

  // Validating the Image (userfile)
  if (empty($userfile))
	 $errorArray['Image File'] = "Browse and select a GIF/JPEG Image File to upload!";
  elseif (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif"))
	 $errorArray['Uploaded Image'] = "Your uploaded file must be either JPG or GIF only!";
  elseif (!doesuserfile_nameEventBannerExist($userfile_name))
	 $errorArray['Uploaded Image'] = "Filename already Exists, Rename and Upload again!";

 

Please help !

 

Thank you :)

What do you mean with "not work"? We need specifics, otherwise we cannot help. If you get error messages, post them here. If you don't, make sure you've got error reporting turned on (or check the error logs).

 

Also, please post more of your code, so that we can see exactly what happens prior to the problem.

 

I recommend that you read this article.

It sounds like GoDaddy has the register_globals directive enabled (which is a BAD thing) and you're relying on that. You should fix your scripts to not rely on this setting. In this particular case that means using the $_FILES superglobal to access your file upload details:

         if (empty($_FILES['userfile']))
                $errorArray['Image File'] = "Browse and select a GIF/JPEG Image File to upload!";
         elseif (!($_FILES['userfile']['type'] =="image/pjpeg" OR $_FILES['userfile']['type']=="image/gif"))
                $errorArray['Uploaded Image'] = "Your uploaded file must be either JPG or GIF only!";
         elseif (!doesuserfile_nameEventBannerExist($_FILES['userfile']['name']))
                $errorArray['Uploaded Image'] = "Filename already Exists, Rename and Upload again!";

Define: But doesn't work either.

 

We are not standing right next to you and don't know what you saw in front of you.

 

Sorry, I meant that the modified code provided by kicken in post #4 does not work.

I have error reporting turned fully on and there's no error.

And the only validation error I get from the form is:

  • Image File: Browse and select a GIF/JPEG Image File to upload!

Assuming that nothing is going on in your form to make it invalid when moving between the different servers (such as a dynamically produced name='...' attribute that is empty), the $_FILES array can be empty due to -

  1. The total size of the form data exceeded the post_max_size setting.
  2. If uploads are not enabled.

What does a phpinfo statement show for the post_max_size and file_uploads settings and what size of file did you try to upload?

Edited by PFMaBiSmAd

Assuming that nothing is going on in your form to make it invalid when moving between the different servers (such as a dynamically produced name='...' attribute that is empty), the $_FILES array can be empty due to -

  1. The total size of the form data exceeded the post_max_size setting.
  2. If uploads are not enabled.

What does a phpinfo statement show for the post_max_size and file_uploads settings and what size of file did you try to upload?

 

PFMaBiSmAd,

Found out two issues, one was completely my fault, I forgot to put the following in the opening form tag:

enctype="multipart/form-data"

The only issue I'm stuck on is that when I use the following for my DocType, the upload does not work:

<!DOCTYPE HTML>

 

But if I use the following DocType, it works just fine:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

 

To answer your questions:

post_max_size is set to 8M and I'm trying to upload a jpg image of about 200kb

file_uploads are ON

max_file_uploads is set to 20

I have an identical code on BlueHost and GoDaddy.

On BlueHost it does NOT work and on GoDaddy it works just fine.

 

I forgot to put the following in the opening form tag: enctype="multipart/form-data"

 

So the code wasn't identical.

 

As to the current problem, I'm not aware of the doctype affecting uploading. It's more likely you changed your form tag but didn't refresh the page to get the changes to take effect in the form already in the browser or you have some invalid HTML somewhere on the form page that is breaking the upload form or you tried a file that was too large or it didn't have a mime type that your code expected.

So the code wasn't identical.

 

As to the current problem, I'm not aware of the doctype affecting uploading. It's more likely you changed your form tag but didn't refresh the page to get the changes to take effect in the form already in the browser or you have some invalid HTML somewhere on the form page that is breaking the upload form or you tried a file that was too large or it didn't have a mime type that your code expected.

 

Hi PFMaBiSmAd,

Yes, just that multipart spot.

Since then, I knew that I was losing things here and there so I have done a line by line check of the code.

It is correct.

The only difference is the DocType.

Files I'm trying to upload are about 200kb (actually lesser, but not more).

I'll keep trying and thanks for your help, I do appreciate every bit of it!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.