Cant get upload class to work.

Any problems relating to the premium downloads should go in here
Post Reply
robg1981
Posts: 13
Joined: Fri Dec 16, 2011 8:54 am

Cant get upload class to work.

Post by robg1981 »

Hi

This is my first post and dont know if this is the exact place to post it but here goes.

Basically i am using this to upload video to the server from admin of clients new website.

I am using this like this:

[syntax=php]
if($video_mp4['size'] == 0){

$errors[] = "No MP4 Video Was Inserted";

} else {

if($video_ogv['size'] == 0){

$errors[] = "No OGV Video Was Inserted";

} else {

$video_mp4 = new secure_upload('video');
$video_mp4->set_type_whitelist(array('video'));
$video_mp4->set_extension_whitelist(array('mp4'));
$video_mp4->save_to('/video/main/' . $video_mp4->name);

if ($video_mp4->error > 0){

$errors[] = "Your mp4: " . $video_mp4->get_error_constant_name();

} else {

$video_ogv = new secure_upload('video');
$video_ogv->set_type_whitelist(array('video'));
$video_ogv->set_extension_whitelist(array('ogv'));
$video_ogv->save_to('/video/main/' . $video_ogv->name);

if ($video_ogv->error > 0){

$errors[] = "Your OGV: " . $video_ogv->get_error_constant_name();

} else {

//insert into database here
returnheader("/admin-area/dash/");

}
[/syntax]


I get the following php errors:

Notice: Undefined index: video in C:\wamp\www\applications\controllers\upload-class.php on line 42
Notice: Undefined index: video in C:\wamp\www\applications\controllers\upload-class.php on line 43
Notice: Undefined index: video in C:\wamp\www\applications\controllers\upload-class.php on line 47
Notice: Undefined index: video in C:\wamp\www\applications\controllers\upload-class.php on line 48
Notice: Undefined index: video in C:\wamp\www\applications\controllers\upload-class.php on line 49

and then the final error report from the class is as follows:

E_INVALID_FILE_NAME

But that error is not correct as the file is the correct mp4 as allowed whitelist is telling it to accept.
robg1981
Posts: 13
Joined: Fri Dec 16, 2011 8:54 am

Re: Cant get upload class to work.

Post by robg1981 »

Ok the problem was the new_secure_upload should be file name instead of video which i was inputting so it was not submitting the file.

I am now getting E_DISK_SPACE which is disk_free_space() function which is not telling the truth.

The file is 40mb and i have 2tb as this is my local computer i am testing it on through WAMP

How do i solve this?
robg1981
Posts: 13
Joined: Fri Dec 16, 2011 8:54 am

Re: Cant get upload class to work.

Post by robg1981 »

Ok i took out the function that checks for disk space and now i get the problem E_DISALLOWED_MIME

Which is impossible.

My white list mime is video/mpeg which a mp4 is so i do not understand.

Everytime i get past an error i get another straight after :(
robg1981
Posts: 13
Joined: Fri Dec 16, 2011 8:54 am

Re: Cant get upload class to work.

Post by robg1981 »

ive even tried video/mp4 and video/MPEG-4 and video/mp4-es and none according to this are correct.

The funny thing is once the error checks are gone with the mp4 then the ogv file which is also being uploaded will then find errors.

Can i please get help :)
robg1981
Posts: 13
Joined: Fri Dec 16, 2011 8:54 am

Re: Cant get upload class to work.

Post by robg1981 »

I have got this working.

For some reason the class is thinking that the mime type is a application/ogg for a .ogv file which infact a .ogv is video/ogg

Im not bothered but can this be a risk as this means someone can upload an application now :(
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Cant get upload class to work.

Post by jacek »

Sorry for not getting back to you, I have not had an internet connections for a few days.

The reason that it gets the mime wrong will be down to your server config, the magic.mime file more specifically will need updating.

Allowing applications will pretty much all any type of file as long as your restrict the extensions it should not be a problem.
Image
robg1981
Posts: 13
Joined: Fri Dec 16, 2011 8:54 am

Re: Cant get upload class to work.

Post by robg1981 »

Cheers, I think its my local computer as its only WAMP i am on, as i can see windows seems to be having problems with the mime method you have done but i noticed everyone who has had problems, not one are live sites on a linux server.

Im sure it will notice the mime when i finally finish the site and upload it to the server.

Ive also extended the class a little by making it assign a random number at the end of it.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Cant get upload class to work.

Post by jacek »

robg1981 wrote:Cheers, I think its my local computer as its only WAMP i am on, as i can see windows seems to be having problems with the mime method you have done but i noticed everyone who has had problems, not one are live sites on a linux server.

Ah, there is he problem then. Windows tends to do things that make no sense ;)

Like you said the best thing to do would be just to assume it will work on the server and make a note to test it once you upload.

robg1981 wrote:Ive also extended the class a little by making it assign a random number at the end of it.

A few people have asked about that, I will probably update the actual item to include a way to do this. :D
Image
Post Reply