導航:首頁 > IDC知識 > 上傳到圖片伺服器

上傳到圖片伺服器

發布時間:2020-12-29 03:03:52

1、圖片先上傳到伺服器中,然後怎麼從伺服器中獲取圖片

你的伺服器

可以自行開設web服務
或者簡單的開一個站點
然後圖片傳到網站的目錄中
直接調用web路徑就可以了
比如http://127.0.0.1/web/123.jpg

2、怎樣將圖片上傳到伺服器

工具/原料 FlashFXP VPN 文件夾步驟/方法 首先建立一個文件夾,把當天需要上傳的圖片存放到同一個文件夾,這樣不會和以前的圖片混淆一起難以辨認。然後就是連接到VPN,輸入VPN用戶名以及密碼,連接成功。打開FlashFXP,這個工具是上傳圖片的直接工具,首先連接到伺服器,點擊圓圈箭頭處的連接圖標,輸入連接類型、用戶名、密碼,連接成功。在FlashFXP工具的左欄的圓圈處打開開始創建的新文件夾,在FlashFXP工具的左欄的圓圈處打開一個新文件夾,這個很重要,最好是每天上傳圖片到伺服器中建立一個新的文件夾。將要上傳的圖片直接復制、粘貼到左欄框內,點擊滑鼠右鍵彈出的傳輸指令,然後上傳到伺服器成功。圖片上次伺服器已成功,然後就可以用代碼的格式編輯到文章中。注意事項 最好是每天上傳圖片到伺服器中建立一個新的文件夾。文件夾不要隨便更改其初始位置。圖片修改成較容易記的名稱,因為在插入圖片時要用源代碼的形式輸入圖片名稱。 更多精彩電腦信息,請登錄:中國高速網-IT頻道。

3、如何上傳Imageview中得圖片到後台伺服器

Imageview中的圖片應該是你的程序設置的,你把圖片直接傳給你的後台伺服器的某個webservice不就行了嗎?

4、本地電腦的圖片怎麼上傳到伺服器

如果你是通過後台,打開伺服器,然後把文件拖進去~~~ 如果你是指上傳到網站 網盤等地方。點擊上傳,然後選擇圖片,然後確定。如果沒有上傳這個選項,則上傳不了。

5、java上傳圖片到遠程伺服器上,怎麼解決呢?

需要這樣的一個包 jcifs-1.1.11
public static void forcdt(String dir){
InputStream in = null;
OutputStream out = null;
File localFile = new File(dir);
try{
//創建file類 傳入本地文件路徑
//獲得本地文件的名字
String fileName = localFile.getName();
//將本地文件的名字和遠程目錄的名字拼接在一起
//確保上傳後的文件於本地文件名字相同
SmbFile remoteFile = new SmbFile("smb://administrator:[email protected]/e$/aa/");
//創建讀取緩沖流把本地的文件與程序連接在一起
in = new BufferedInputStream(new FileInputStream(localFile));
//創建一個寫出緩沖流(注意jcifs-1.3.15.jar包 類名為Smb開頭的類為控制遠程共享計算機"io"包)
//將遠程的文件路徑傳入SmbFileOutputStream中 並用 緩沖流套接
out = new BufferedOutputStream(new SmbFileOutputStream(remoteFile+"/"+fileName));
//創建中轉位元組數組
byte[] buffer = new byte[1024];
while(in.read(buffer)!=-1){//in對象的read方法返回-1為 文件以讀取完畢
out.write(buffer);
buffer = new byte[1024];
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
//注意用完操作io對象的方法後關閉這些資源,走則 造成文件上傳失敗等問題。!
out.close();
in.close();
}catch(Exception e){
e.printStackTrace();}
}
}

6、我要在一個網頁上傳一張圖片到伺服器,然後保存圖片的地址,在另一個頁面顯示圖片

public class UploadAction extends ActionSupport {
//接收文件 名稱需要和表單name名稱一致
private File image;
//上傳多個圖片文件
private File[] images;
//上傳文件類型[image]為表單name名稱,ContentType為固定寫法
private String imageContentType;
private String[] imagesContentType;
//上傳文件名稱[image]為表單name名稱,FileName為固定寫法
private String imageFileName;
private String[] imagesFileName;

//上傳一個文件
public String upload(){
//將長傳的文件存儲到images文件夾下,首先根據images名稱得到具體路徑
String realPath = ServletActionContext.getServletContext().getRealPath("images");
File file = new File(new File(realPath),imageFileName);
//如果輸入為空 沒選擇圖片的話
if(image != null){
//判斷文件夾存不存在
if(!file.getParentFile().exists()){
file.getParentFile().mkdir(); //創建一個文件夾
}
try {
FileUtils.copyFile(image, file);
super.addActionError("上傳成功");
} catch (IOException e) {
super.addActionError("上傳失敗");
e.printStackTrace();
}
}
return SUCCESS;
}
//上傳多個文件
public String manyUpload(){
//將長傳的文件存儲到images文件夾下,首先根據images名稱得到具體路徑
String realPath = ServletActionContext.getServletContext().getRealPath("images");
System.out.println(realPath);
File file =null;
if(images != null){
try {
for (int i = 0; i <images.length ; i++) {
file = new File(new File(realPath),imagesFileName[i]);
FileUtils.copyFile(images[i], file);
}
super.addActionError("上傳成功");
} catch (IOException e) {
super.addActionError("上傳失敗");
e.printStackTrace();
}
}
return SUCCESS;
}

public File getImage() {
return image;
}
public void setImage(File image) {
this.image = image;
}
public String getImageContentType() {
return imageContentType;
}
public void setImageContentType(String imageContentType) {
this.imageContentType = imageContentType;
}
public String getImageFileName() {
return imageFileName;
}
public void setImageFileName(String imageFileName) {
this.imageFileName = imageFileName;
}
public File[] getImages() {
return images;
}
public void setImages(File[] images) {
this.images = images;
}
public String[] getImagesContentType() {
return imagesContentType;
}
public void setImagesContentType(String[] imagesContentType) {
this.imagesContentType = imagesContentType;
}
public String[] getImagesFileName() {
return imagesFileName;
}
public void setImagesFileName(String[] imagesFileName) {
this.imagesFileName = imagesFileName;
}
}

7、已知本地文件路徑,怎樣將圖片上傳到伺服器

你升級到ie8了么?
安裝完internet
explorer
8後把被更改的瀏覽器安全設置中的【將文件上傳到伺服器時包含本地目錄路徑】下面這一項為「啟用」。

8、jquery如何將頁面生成的圖片上傳到伺服器

File Upload組件啊,是同步還是非同步呢
html部分:
<input type="file" name="file" class="webuploader-element-invisible" multiple="multiple" accept="image/*">
文件引入:
<link rel="stylesheet" type="text/css" href="diyUpload/css/diyUpload.css"><script type="text/javascript" src="diyUpload/js/diyUpload.js"></script>
HTML部分:
<div id="demo"> <div id="as" ></div></div>
JS部分:
<script type="text/javascript">
/** 伺服器地址,成功返回,失敗返回參數格式依照jquery.ajax習慣;* 其他參數同WebUploader*/
$('#as').diyUpload({
url:'server/fileupload.php',
success:function( data ) {
console.info( data ); },
error:function( err ) {
console.info( err );
},
buttonText : '選擇文件', chunked:true, // 分片大小
chunkSize:512 * 1024, //最大上傳的文件數量, 總文件大小,單個文件大小(單位位元組);
fileNumLimit:50,
fileSizeLimit:500000 * 1024,
fileSingleSizeLimit:50000 * 1024,
accept: {}});
</script>

9、java實現圖片上傳至伺服器並顯示,如何做?

給你段代碼,是用來在ie上顯示圖片的(servlet):

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id = request.getParameter("id");
File file = new File(getServletContext().getRealPath("/")+"out"+"/"+id+".gif");
response.setCharacterEncoding("gb2312");
response.setContentType("doc");
response.setHeader("Content-Disposition", "attachment; filename=" + new String(file.getName().getBytes("gb2312"),"iso8859-1"));

System.out.println(new String(file.getName().getBytes("gb2312"),"gb2312"));

OutputStream output = null;
FileInputStream fis = null;
try
{
output = response.getOutputStream();
fis = new FileInputStream(file);

byte[] b = new byte[1024];
int i = 0;

while((i = fis.read(b))!=-1)
{

output.write(b, 0, i);
}
output.write(b, 0, b.length);

output.flush();
response.flushBuffer();
}
catch(Exception e)
{
System.out.println("Error!");
e.printStackTrace();
}
finally
{
if(fis != null)
{
fis.close();
fis = null;
}
if(output != null)
{
output.close();
output = null;
}
}

}

這個程序的功能是根據傳入的文件名(id),來為瀏覽器返回圖片流,顯示在<img>標簽里
標簽的格式寫成如下:
<img src="http://localhost:8080/app/preview?id=111 "/><br/>
顯示的是111.gif這個圖片

你上面的問題:
1.我覺得你的第二個辦法是對的,我們也是這樣做的,需要的是把資料庫的記錄id號傳進servlet,然後讀取這條記錄中的路徑信息,生成流以後返回就是了

關於上傳文件的問題,我記得java中應該專門有個負責文件上傳的類,你調用就行了,上傳後存儲在指定的目錄里,以實體文件的形式存放
你可以參考這個:
http://blog.csdn.net/arielxp/archive/2004/09/28/119592.aspx

回復:
1.是的,在response中寫入流就行了
2.是發到servlet中的,我們一般都是寫成servlet,短小精悍,使用起來方便,struts應該也可以,只是我沒有試過,恩,你理解的很對

10、html和css還有圖片怎麼上傳到伺服器裡面

我也遇到同樣的問題。我的網站在公司顯示好好的。資料庫和網站都備份打包後在我家回的機子上就沒了樣答式,那個都是相對路徑。也不知道問題出在那。如果你的問題解決了,麻煩說下你的解決辦法。我估計是你網站路徑設置的問題。

與上傳到圖片伺服器相關的知識