I'm setting up a localhost server, and I want to GET photo src through http://localhost:3000/photos/, but It doesn't save photo src to .txt file.
I've already tried in server.js:
app.get('/phofn', function(req, res){
fs.readFile('Photo.txt', function(err, data){
res.send(data);
});
});
app.get('/photos/:poto', function(req, res) {
var foto = req.src.poto
fs.appendFile('Photo.txt',foto, function (err) {
if (err) throw err;
console.log('Saved!');
});
fs.readFile('Photo.txt', function(err, data) {
res.send(data);
res.end();
});
});
And this in HTML:
function loadDoc() {
var photo = document.getElementById("photo").src;
$.get("http://localhost:3000/photos/" + photo, function(data, status){
alert(data);
console.log(data);
});
}