Hi there,
I am trying to upload an image and display it.

However, it seems that I am missing something: nothing is shown on the web
page.

The code snippet that is supposed to upload and display the image is the
following:

ImageUploadWidgetContainer::ImageUploadWidgetContainer(Wt::WContainerWidget
* parent):
  m_ImageUploadWidget( 0 )
{

// Create the painter widget
m_ImageUploadWidget = new ImageUploadWidget(this)

// Create a WFileUpload
m_FileUpload = new Wt::WFileUpload(this);
m_FileUpload->setFileTextSize(30);

// Provide a button to actually upload the image
Wt::WPushButton *sendButton = new Wt::WPushButton("Send", parent);

// Upload when the button is clicked.
sendButton->clicked().connect(this,
&ImageUploadWidgetContainer::UploadFile);

// React to a successful upload.
 m_FileUpload->uploaded().connect(this,
&ImageUploadWidgetContainer::FileUploaded);/

// React to a fileupload problem.
m_FileUpload->fileTooLarge().connect(this,
&ImageUploadWidgetContainer::FileTooLarge);

}

void ImageUploadWidgetContainer::UploadFile()
{
  m_FileUpload->upload();
}

void ImageUploadWidgetContainer::FileUploaded()
{
// spoolFileName is the place where the content the user loaded is stocked
// Set the resource location
m_ImageUploadWidget->SetResourceLocation( m_FileUpload->spoolFileName() );

// Trigger a repaint (paintEvent)
  m_ImageUploadWidget->update();
}

void ImageUploadWidget::SetResourceLocation(Wt::WString spoolFileName)
{
m_SpoolFileName = spoolFileName;
}

void ImageUploadWidget::paintEvent(Wt::WPaintDevice *paintDevice)
{
if( !m_SpoolFileName.empty() )
{
   Wt::WPainter painter(paintDevice);
// Actually, draw the image (just assuming the file is an image...)
Wt::WPainter::Image* image = new Wt::WPainter::Image(
m_SpoolFileName.toUTF8(),  200, 200);
    painter.drawImage(20, 20, *image);
}

}


Am I missing something or is there something I should understand prior to
successfully uploading and displaying a local image?

Thanks,
JON HAITZ
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to