myapp/src/components/views/parts/Upload.js
//upload photo upon click on submit button
upload photo upon click on submit button
upload photo upon click on submit button
updateSubmit()
        {
	    var fd = new FormData();
	    fd.append("image_category", this.state.categories1[this.state.category]);
	    fd.append("image_description", this.state.des);
	    fd.append("uploaded_by", 'Arnold');
	    fd.append("image", this.state.file, this.state.file.name);
            axios({
                method: 'post',
                url: 'https://hatboxphotos.com/images/',
                'Content-Type': 'multipart/form-data',
                data: fd
            }).then(function (response)
	    {
		console.log("UPLOAD", response.data);
		if(response.status && response.status === 201)
		{			
                	alert("Upload successfully! Admin will approve or decline in 24-48 hours.");
			window.location.reload();
		}
		else
		{
			alert("Upload failed, err-msg: " + response.message);
		}
            }).catch(function (error)
            {
                alert("Upload failed, err-msg: " + error.message);
            });
	    return false;
        }
updateSubmit ( ) { var fd = new FormData ( ) ; fd . append ( "image_category" , this . state . categories1 [ this . state . category ] ) ; fd . append ( "image_description" , this . state . des ) ; fd . append ( "uploaded_by" , 'Arnold' ) ; fd . append ( "image" , this . state . file , this . state . file . name ) ; axios ( { method : 'post' , url : 'https://hatboxphotos.com/images/' , 'Content-Type' : 'multipart/form-data' , data : fd } ) . then ( function ( response ) { console . log ( "UPLOAD" , response . data ) ; if ( response . status && response . status === 201 ) { alert ( "Upload successfully! Admin will approve or decline in 24-48 hours." ) ; window . location . reload ( ) ; } else { alert ( "Upload failed, err-msg: " + response . message ) ; } } ) . catch ( function ( error ) { alert ( "Upload failed, err-msg: " + error . message ) ; } ) ; return false ; }
upload photo upon click on submit button
upload photo upon click on submit button
//upload photo to backend // url: 'http://127.0.0.1:8080/images',