51
phillipd
Re: Trying to understand xoopsformfile
  • 2005/2/1 23:19

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I've figured that out already, but it has no reference to xoops_upload_file. It uses php's move_uploaded_file() function. But I still don't understand that how this single line works.

$field = $_POST["xoops_upload_file"][0] ;

What does the "xoops_upload_file" reference?

Still looking...


Damn! I just found it originating in formfile.php in the "render" function. But since the xoopsform file is intended to be passed a text gadget name, why is xoops_upload_file used instead of the passed name?

Doug P



52
phillipd
Re: Upload Form
  • 2005/2/1 21:37

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I've had some luck with the code that winsion posted, but I don't understand how this line works:

$field = $_POST["xoops_upload_file"][0] ;

Where does "xoops_upload_file" come from? It's not in the form code. What is it? Is it a XOOPS thing? And it still, when echoed to the browser, only shows the filename. The path component is missing. But it works, the file is uploaded to the images dir. This is really confounding me, it looks like magic! I would really like to understand this XoopsFormFile mechanism so I may use it with some confidence. Any help here is GREATLY appreciated. What piece of information am I missing?

Thanks

Doug P



53
phillipd
Trying to understand xoopsformfile
  • 2005/2/1 21:36

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I found the following code snippet on this forum and it works but I just don't understand HOW it works. My question is with this line:

$field = $_POST["xoops_upload_file"][0] ;

Where does "xoops_upload_file" come from? It's not in the form code. What is it? Is it a XOOPS thing? And it still, when echoed to the browser, only shows the filename. The path component is missing. But it works, the file is uploaded to the images dir. This is really confounding me, it looks like magic! I would really like to understand this XoopsFormFile mechanism so I may use it with some confidence. Any help here is GREATLY appreciated. What piece of information am I missing?

Thanks

Doug P (Code below)

<?

include("admin_header.php");


$op = 'form';


function form() {

include XOOPS_ROOT_PATH."/class/xoopsformloader.php";
$my_form = new XoopsThemeForm("Upload", "form", "index.php");
$my_form->setExtra( "enctype='multipart/form-data'" ) ;
$img_box = new XoopsFormFile("Image", "photo", $max_imgsize);
$img_box->setExtra( "size ='50'") ;
$my_form->addElement($img_box);
$button_tray = new XoopsFormElementTray('' ,'');
$button_tray->addElement(new XoopsFormButton('', 'post',"Submit", 'submit'));
$my_form->addElement($button_tray);
$my_form->display();
}



foreach ( $_POST as $k => $v ) {
${$k} = $v;
}
if ( isset($post) ) {
$op = 'post';
}

switch ($op) {


case "post":
$max_imgsize = 100000;
$max_imgwidth = 500;
$max_imgheight = 500;
$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
$img_dir = XOOPS_ROOT_PATH . "/modules/mymodule/images" ;

include_once(XOOPS_ROOT_PATH."/class/uploader.php");
$field = $_POST["xoops_upload_file"][0] ;

if( !empty( $field ) || $field != "" ) {


$uploader = new XoopsMediaUploader($img_dir, $allowed_mimetypes, $max_imgsize, $max_imgwidth, $max_imgheight);
$uploader->setPrefix( 'img' ) ;
if( $uploader->fetchMedia( $field ) && $uploader->upload() ) {
$photo=$uploader->getSavedFileName();

} else {
echo $uploader->getErrors();
}
}



break;

case 'form':
default:
xoops_cp_header();

form();

xoops_cp_footer();
break;
}
?>



54
phillipd
Re: Upload Form
  • 2005/1/27 16:51

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Whenever I use "XoopsFormFile" to get a path to a file, when I POST it all I get is the filename, the directory part is missing. Do you have this same problem? What am I missing here???

Thanks

Doug P



55
phillipd
Re: Base path of a pathname disappears from xoopsFormFile
  • 2005/1/27 15:32

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Am I asking a dumb question? This is the first question that hasn't been answered. How about if I add some source:

FORM:

$filegad = new XoopsFormFile('Attachment', 'upload_file', 2000000);
$file_tray = new XoopsFormElementTray("", "&nbsp;");
$file_tray->addElement($filegad);
$entryform->addElement($file_tray);

$entryform->addElement($submit);
$entryform->addElement($button);
$entryform->display();

I select /home/phillipd/somefile.jpeg from the file selector.


REcieving script

$allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png');
$maxfilesize = 50000;
$maxfilewidth = 120;
$maxfileheight = 120;
$uploader = new XoopsMediaUploader('/home/xoops/uploads', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);

if ($uploader->fetchMedia($_POST['uploade_file'])) {
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
echo '<h4>File uploaded successfully!</h4>';
echo 'Saved as: ' . $uploader->getSavedFileName() . '<br />';
echo 'Full path: ' . $uploader->getSavedDestination();
}
} else {
echo $uploader->getErrors();
}

If I $_POST['upload_file']; I get "somefile.jpeg". Where did the path component go?

Thanks

Doug P



56
phillipd
Base path of a pathname disappears from xoopsFormFile
  • 2005/1/26 17:42

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I'm trying to use xoopsformfile and xoopsmediauploader to upload some files. Whenever I $_POST the xoopsformfile contents all I get is the basename of the file, the dirname is missing. What am I doing wrong? I've looked at other examples from other modules and I'm doing about the same thing.

Can someone please tell me why when I POST the XoopsFormFile gadget, in my recieving script all I get is the filename without the directory path component?


Perplexed

Doug P



57
phillipd
A little info
  • 2005/1/25 18:27

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Where can I find specific info on what "getVar" can provide me?

Also, where do I find exactly what XOOPS variables I have access to in my php scripts? Is this documented anywhere?

Thanks

Doug P



58
phillipd
Re: How to show the count of registered members on homepage?
  • 2005/1/20 20:27

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


How do I get my user information? Full name, username and such?

Ahh, I see: $xoopsUser->getVar('uname');

Where can I find specific info on what "getVar" can provide me?

Also where do I find exactly what XOOPS variables I have access to in my php scripts? Is this documented anywhere?

Thanks

Doug P



59
phillipd
Reserved words for templates???
  • 2005/1/19 23:32

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I created an admin template called main.html and was having a terrible time getting it to work properly. I then renamed it in xoops_version, my code, etc to darmain.html and everything started working properly. After everything was debugged and 100% working, I went back to the main.html name for that template and it all went to hell again. Are there any reserved names for templates?

Thanks

Doug P



60
phillipd
Re: My own module
  • 2005/1/13 21:39

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


That works great, thanks!

Doug P




TopTop
« 1 ... 3 4 5 (6) 7 8 9 ... 22 »



Login

Who's Online

242 user(s) are online (179 user(s) are browsing Support Forums)


Members: 0


Guests: 242


more...

Donat-O-Meter

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

Latest GitHub Commits