1. Téléchargez SinaEditor
2.Page d'appel JSP
Copiez le code comme suit :
<textarea name="problemBody" id="content" style="display:none;"
<iframe src="<%=request.getContextPath() %>/edit/editor.htm?id=content&ReadCookie=0" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No">< /iframe>
Parmi eux, src="<%=request.getContextPath() %>/edit/editor.htm représente le chemin du fichier editor.htm dans le SinaEditor téléchargé ; les deux ID en vert doivent être cohérents
3. L'éditeur téléchargé contient img.htm et attach.htm. Le premier est destiné au téléchargement d'images et le second est destiné au téléchargement de pièces jointes. Bien entendu, les deux sont utilisés de la même manière et peuvent être considérés comme du téléchargement de fichiers.
4. Ce qui suit est un exemple de téléchargement d'images dans img.htm. Prenez note pour une utilisation future.
Copiez le code comme suit :
fonction chk_imgpath () {
if($('radio1').checked==true){
if($("imgpath").value == "http://" || $("imgpath").value == "") {
window.close();
retour;
}
LoadIMG($("imgpath").value);
}autre{
if($("file1").value == "") {
alert("Veuillez choisir de télécharger des fichiers image !");
retour;
}
var filepath = j("#file1").val();
var filetype = filepath.substring(filepath.lastIndexOf('.'));
var regu = ".gif.jpg.png.jpge.GIF.JPG.PNG";
if (regu.indexOf(filetype) == -1) {
alert('Seuls les fichiers de type .gif.jpg.png.jpge peuvent être téléchargés !');
retour ;
}
var f = j('#form1');
j.ajaxFileUpload({
tapez : 'POST',
secureuri : faux,
fileElementId : 'fichier1',
URL : '/ask/fileUpload?type=img',
dataType : 'Chaîne',
succès : fonction (données) {
j("#imgpath").attr("valeur",données);
j("#radio1").attr("checked","true");
chk_imgpath();
$('divProcessing').style.display='';
},
erreur : fonction (données) {
alert('Échec du téléchargement du fichier');
}
});
}
}
5. Écriture de code backend (pas de description)