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..

<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 '<h4>File uploaded successfully!</h4>';
echo 'Saved as: ' . $uploader->getSavedFileName() . '<br />';
echo 'Full path: ' . $uploader->getSavedDestination();
redirect_header("unzip.php",1,'Module Successfully Uploaded <br> Saved as: $uploader->getSavedFileName() <br> Full path: $uploader->getSavedDestination()' );
}
} else {
redirect_header("unzip.php",1,$uploader->getErrors());
echo $uploader->getErrors();
}
}
</code>

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 <code> 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 <code> 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.