• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 542
  • Last Modified:

Attach file and upload file through url

Hi,

I'm wondering if it's possible to upload a file through url. For example, I got an image on my local computer, c:\image.png. I want to attach this file name with full path to a url: http://www.myimagerepo.com/images.html?image=c:\image.png. My application will load the file and display in the browser.

Thanks a lot for the help.

Ming
0
mybluegrass
Asked:
mybluegrass
1 Solution
 
andeporterCommented:
Are you attempting to do this across the internet?
0
 
hieloCommented:
>>I'm wondering if it's possible to upload a file through url.
No. You have to use a <form> and use the <input type="file"> element. Furthemore, the user must manually select the file. These features are in place for security reasons.
0
 
mybluegrassAuthor Commented:
Let me rephrase it. My main purpose is to be able to pass an image file located in my local computer to my web based application which is installed on a different linux server. I know now that automatically upload won't work, but is there a way to pass the image data, say, the bytes through the post method?

Thanks!

Ming
0
 
hieloCommented:
Again, for security reasons, the user MUST choose the file manually. If that were not the case I would be able to lure you to my site and visit some page with the following code:
<script>
window.onload=function(){
  document.getElementById('theForm').submit();
}
</script>
<form id='theForm' action='dataStealer.php' method='post' enctype='multipart/form-data'>
 <input type='file' value='C:\test.doc' />
</form>

Then in the processing file I would just save the file and then redirect you to a legitimate page.  So there, I would have stolen your file without your knowledge. For this reason, even pre-setting the file name in the value of the input field is ignored by the browser. It will only send/submit the file unless the user chooses the file manually.
0
 
dereck2008Commented:
You do need <input type='file' .. for HTML upload. Another solution could be an applet that will upload file for you. You have on at http://www.jfileupload.com
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now