cfs collection showing error in react.component
I have cfs collection for file uploading. I have already used this in the template and its working well. Now I have to use this react.component but its showing this error Uncaught ReferenceError: fsFile is not defined
. I have added FS.Collection but its still showing error. Its working in when I using the template but not working in the react component. How can I solve this?
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import React from 'react';
import Switch from 'react-switch';
import {Events} from './../../api/events';
import DatePicker from "react-datepicker";
import moment from "moment";
import "react-datepicker/dist/react-datepicker.css";
export default class AddEvent extends React.Component{
EventForm(e){
e.preventDefault();
let eventTitle = e.target.title.value;
let file = $('#projectImage').get(0).files[0];
if(file){
fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
if(!err){
var projectImage = '/cfs/files/ProjectImages/' + result._id;
// Insert Project
Events.insert({
name: eventTitle,
projectImage: projectImage
});
}
});
} else {
// Insert Project
Events.insert({
name: eventTitle
});
}
}
render(){
return(
<div className="tab-pane fade" id="upEvents">
<form className="upload-event-from" onSubmit={this.EventForm.bind(this)}>
<div className="form-group">
<input type="text" className="form-control" id="event_title" placeholder="Event Title" name="title" />
<span className="error-message eventTitle"></span>
</div>
<div className="form-group fg-icon">
<label>Upload Image</label>
<input type="file" className="form-control" name="projectImage" id="projectImage" />
<img id="blah" src="#" alt="your image" />
</div>
<center>
<button type="submit" className="btn app-btn">Publish</button>
</center>
</form>
</div>
);
}
}
javascript reactjs meteor react-component cfs
add a comment |
I have cfs collection for file uploading. I have already used this in the template and its working well. Now I have to use this react.component but its showing this error Uncaught ReferenceError: fsFile is not defined
. I have added FS.Collection but its still showing error. Its working in when I using the template but not working in the react component. How can I solve this?
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import React from 'react';
import Switch from 'react-switch';
import {Events} from './../../api/events';
import DatePicker from "react-datepicker";
import moment from "moment";
import "react-datepicker/dist/react-datepicker.css";
export default class AddEvent extends React.Component{
EventForm(e){
e.preventDefault();
let eventTitle = e.target.title.value;
let file = $('#projectImage').get(0).files[0];
if(file){
fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
if(!err){
var projectImage = '/cfs/files/ProjectImages/' + result._id;
// Insert Project
Events.insert({
name: eventTitle,
projectImage: projectImage
});
}
});
} else {
// Insert Project
Events.insert({
name: eventTitle
});
}
}
render(){
return(
<div className="tab-pane fade" id="upEvents">
<form className="upload-event-from" onSubmit={this.EventForm.bind(this)}>
<div className="form-group">
<input type="text" className="form-control" id="event_title" placeholder="Event Title" name="title" />
<span className="error-message eventTitle"></span>
</div>
<div className="form-group fg-icon">
<label>Upload Image</label>
<input type="file" className="form-control" name="projectImage" id="projectImage" />
<img id="blah" src="#" alt="your image" />
</div>
<center>
<button type="submit" className="btn app-btn">Publish</button>
</center>
</form>
</div>
);
}
}
javascript reactjs meteor react-component cfs
I am not seeing FS defined anywhere. Am I missing something??
– klvenky
Nov 23 '18 at 6:48
add a comment |
I have cfs collection for file uploading. I have already used this in the template and its working well. Now I have to use this react.component but its showing this error Uncaught ReferenceError: fsFile is not defined
. I have added FS.Collection but its still showing error. Its working in when I using the template but not working in the react component. How can I solve this?
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import React from 'react';
import Switch from 'react-switch';
import {Events} from './../../api/events';
import DatePicker from "react-datepicker";
import moment from "moment";
import "react-datepicker/dist/react-datepicker.css";
export default class AddEvent extends React.Component{
EventForm(e){
e.preventDefault();
let eventTitle = e.target.title.value;
let file = $('#projectImage').get(0).files[0];
if(file){
fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
if(!err){
var projectImage = '/cfs/files/ProjectImages/' + result._id;
// Insert Project
Events.insert({
name: eventTitle,
projectImage: projectImage
});
}
});
} else {
// Insert Project
Events.insert({
name: eventTitle
});
}
}
render(){
return(
<div className="tab-pane fade" id="upEvents">
<form className="upload-event-from" onSubmit={this.EventForm.bind(this)}>
<div className="form-group">
<input type="text" className="form-control" id="event_title" placeholder="Event Title" name="title" />
<span className="error-message eventTitle"></span>
</div>
<div className="form-group fg-icon">
<label>Upload Image</label>
<input type="file" className="form-control" name="projectImage" id="projectImage" />
<img id="blah" src="#" alt="your image" />
</div>
<center>
<button type="submit" className="btn app-btn">Publish</button>
</center>
</form>
</div>
);
}
}
javascript reactjs meteor react-component cfs
I have cfs collection for file uploading. I have already used this in the template and its working well. Now I have to use this react.component but its showing this error Uncaught ReferenceError: fsFile is not defined
. I have added FS.Collection but its still showing error. Its working in when I using the template but not working in the react component. How can I solve this?
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import React from 'react';
import Switch from 'react-switch';
import {Events} from './../../api/events';
import DatePicker from "react-datepicker";
import moment from "moment";
import "react-datepicker/dist/react-datepicker.css";
export default class AddEvent extends React.Component{
EventForm(e){
e.preventDefault();
let eventTitle = e.target.title.value;
let file = $('#projectImage').get(0).files[0];
if(file){
fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
if(!err){
var projectImage = '/cfs/files/ProjectImages/' + result._id;
// Insert Project
Events.insert({
name: eventTitle,
projectImage: projectImage
});
}
});
} else {
// Insert Project
Events.insert({
name: eventTitle
});
}
}
render(){
return(
<div className="tab-pane fade" id="upEvents">
<form className="upload-event-from" onSubmit={this.EventForm.bind(this)}>
<div className="form-group">
<input type="text" className="form-control" id="event_title" placeholder="Event Title" name="title" />
<span className="error-message eventTitle"></span>
</div>
<div className="form-group fg-icon">
<label>Upload Image</label>
<input type="file" className="form-control" name="projectImage" id="projectImage" />
<img id="blah" src="#" alt="your image" />
</div>
<center>
<button type="submit" className="btn app-btn">Publish</button>
</center>
</form>
</div>
);
}
}
javascript reactjs meteor react-component cfs
javascript reactjs meteor react-component cfs
asked Nov 23 '18 at 6:39
KaneKane
549
549
I am not seeing FS defined anywhere. Am I missing something??
– klvenky
Nov 23 '18 at 6:48
add a comment |
I am not seeing FS defined anywhere. Am I missing something??
– klvenky
Nov 23 '18 at 6:48
I am not seeing FS defined anywhere. Am I missing something??
– klvenky
Nov 23 '18 at 6:48
I am not seeing FS defined anywhere. Am I missing something??
– klvenky
Nov 23 '18 at 6:48
add a comment |
1 Answer
1
active
oldest
votes
The issue in that fsFile = new FS.File(file);
line, you didn't declare the let
but below of this line you called this again, I hope the issue happening from there, use like below
let fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
....
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441728%2fcfs-collection-showing-error-in-react-component%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issue in that fsFile = new FS.File(file);
line, you didn't declare the let
but below of this line you called this again, I hope the issue happening from there, use like below
let fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
....
add a comment |
The issue in that fsFile = new FS.File(file);
line, you didn't declare the let
but below of this line you called this again, I hope the issue happening from there, use like below
let fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
....
add a comment |
The issue in that fsFile = new FS.File(file);
line, you didn't declare the let
but below of this line you called this again, I hope the issue happening from there, use like below
let fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
....
The issue in that fsFile = new FS.File(file);
line, you didn't declare the let
but below of this line you called this again, I hope the issue happening from there, use like below
let fsFile = new FS.File(file);
ProjectImages.insert(fsFile, function(err, result){
....
answered Nov 23 '18 at 8:22
fool-devfool-dev
5,67572440
5,67572440
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441728%2fcfs-collection-showing-error-in-react-component%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am not seeing FS defined anywhere. Am I missing something??
– klvenky
Nov 23 '18 at 6:48