1
kaotik
Image upload not being saved to directory
  • 2004/9/30 11:58

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


I'm using the folowing code. Can someone tell me why it's not saving to the directory I specified?
Any help would be greatly apreciated.

include("../../mainfile.php");


$op 'form'

function 
form() {
$max_imgsize 10000000;
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 10000000
$max_imgwidth 50000
$max_imgheight 50000
$allowed_mimetypes = array('image/gif''image/jpeg''image/pjpeg''image/x-png');
$img_dir XOOPS_ROOT_PATH "/modules/WebMailFX/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:

form();

break;
}

2
flyingtux
Re: Image upload not being saved to directory
  • 2004/9/30 13:28

  • flyingtux

  • Not too shy to talk

  • Posts: 146

  • Since: 2004/9/6 1


Hi kaotik!
Why don't try to have a look at the xoopsgallery code? It perfectly uploads files in the specified directory.

Login

Who's Online

140 user(s) are online (74 user(s) are browsing Support Forums)


Members: 0


Guests: 140


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