Adam Stephen Docherty
unread,Aug 15, 2012, 1:21:22 AM8/15/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Joomla! General Development
Hello there I am saving files from a XMLHttpRequest (XHR) request and
I just can't get it to work with joomla's framework methods. It seems
that they do different things than their named counterparts in native
PHP. The following code works - commented out are the Joomla methods,
when added they throw errors.
$input = JFactory::getApplication()->input;
$id = $input->get( 'eventid', false, 'int' );
//$stream = JFactory::getStream();
$input = fopen("php://input", "r");
//$input = JFile::read("php://input");
$temp = tmpfile();
stream_copy_to_stream($input, $temp);
//$stream->copy($input, $temp);
fclose($input);
$pathinfo = pathinfo( $input->get( 'qqfile', false, 'string' ) );
$filename = $pathinfo['filename'];
$ext = @$pathinfo['extension']; // hide notices if extension
is empty
$uploadDirectory = dirname( __FILE__ ); //just for testing
$target = fopen( $uploadDirectory . $filename . '.' . $ext, "w" );
//$input = JFile::read("php://input");
fseek( $temp, 0, SEEK_SET );
//$stream->seek($temp, 0, SEEK_SET);
stream_copy_to_stream( $temp, $target );
//$stream->copy( $temp, $target );
fclose( $target );
any advice on this would be very much appreciated.
Kind Regards,
Adam