1
talunceford
Help with some upload code.....

Well, I decided to expand on the upload and extract module, module/hack. One problem, I cant get the upload to work correctly. Ive got the upload code stored in a function, and it seems to hit the function properly, but it errors out as soon as I submit something.... By error out, I mean that it doesn't submit anything and displays the canned error message.

Here is the code..


function xoopsmoduleupload() {
global $HTTP_POST_VARS;
include_once XOOPS_ROOT_PATH.'/class/uploader.php';
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('text/html', 'application/x-cdf', 'text/plain'), 2000000);
$uploader->setPrefix('tmp');
if ($uploader->fetchMedia($HTTP_POST_VARS['upload_file_name'][0])) {
if (!$uploader->upload()) {
$err = $uploader->getErrors();
} else {
echo '

File uploaded successfully!

';
echo 'Saved as: ' . $uploader->getSavedFileName() . '
';
echo 'Full path: ' . $uploader->getSavedDestination();
redirect_header("unzip.php",1,'Module Successfully Uploaded
Saved as: $uploader->getSavedFileName()
Full path: $uploader->getSavedDestination()' );
}
} else {
redirect_header("unzip.php",1,$uploader->getErrors());
echo $uploader->getErrors();
}
}


What am I doing wrong here?

Thanks for the help,

2
talunceford
Re: Help with some upload code.....

NM Got it figured out.

3
Mithrandir
Re: Help with some upload code.....

Quote:
what am I doing wrong
well, for starters, you use instead of with square brackets

Could you post, what you did, which worked?

4
talunceford
Re: Help with some upload code.....

Quote:

MithyT2 wrote:
Quote:
what am I doing wrong
well, for starters, you use instead of with square brackets

Could you post, what you did, which worked?


Yeah yeah, wise guy LOL!

Basically, I found another script that seems to work for what I needed. Check out the post I made for the module to upload / install modules. You can see what I was using the code for.

I think I am going to rewrite the upload function to be less bulky. Pretty confusing the way the author wrote it. Anyway.... check it out and see what you think.

Login

Who's Online

974 user(s) are online (234 user(s) are browsing Support Forums)


Members: 0


Guests: 974


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits