can't get upload to work at all

See all posts See thread Reply

Re: can't get upload to work at all new!
by colin, 11 years, 3 months ago
Make sure you do your tests with a small file, in case of you hitting some limits.

Also make sure that you set the enctype property of your form tag, as following: enctype="multipart/form-data"

And what do you have in your variable $fileToUpload?Reply
Re: can't get upload to work at all new!
by Kathy, 11 years, 3 months ago
I am using a very small file from my PC for just that reason.

I've got the enctype set on my form.

My variable $fileToUpload is $fileToUpload = $this->message_vars['fileName'];, which is correct as I've printed this out to my error log. Could it be that fileToUpload is not found because it is the name of a local file on my filesystem, but $fileToUpload does not contain a path?Reply
Re: can't get upload to work at all new!
by colin, 11 years, 3 months ago
I am not sure what framework you are using.

But you need to instantiate the class with an upload field, that is an value from the array $_FILES. In your code, it seems that your upload file (input type="file") doesn't have a name. It should, and then you use this name to find the correct value in the $_FILES array.

Look at the code sample in the class itself, it is a minimal example showing how to create a form and instantiate the class. In your case, your form fields are incomplete, and cannot work.Reply
Re: can't get upload to work at all new!
by Kathy, 11 years, 3 months ago
Got it. Gave my "input type=file" a name attribute with the value 'attachment', and changed to :
$handle = new Upload($_FILES['attachment']);

Works great now. Thanks so much for the quick responses!Reply