469,286 Members | 2,442 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

how to get complete path while in file uploading

254 100+
Hi

I want to get the complete path of a file when we are uploading any image or file.
Apr 7 '09 #1
15 9308
hsriat
1,654 Expert 1GB
what exactly did you mean?
Apr 10 '09 #2
mukeshrasm
254 100+
@hsriat
when we are uploading file it takes path and I want to get that complete path
Apr 13 '09 #3
mfaisalwarraich
194 100+
when you are trying to upload a file then u have to define a path where u have to move the uploaded file. please go through move_uploaded_file at php.net. this will give u comprehensive details or try to look at google.
Apr 15 '09 #4
mukeshrasm
254 100+
@mfaisalwarraich
Thanks! dude I will definetly look at php.net
Apr 15 '09 #5
mfaisalwarraich
194 100+
mukesh try to use getcwd() function this will return the path of the current working directory.

Expand|Select|Wrap|Line Numbers
  1.  
  2. echo getcwd();
  3.  
  4.  
Apr 15 '09 #6
mukeshrasm
254 100+
@mfaisalwarraich
Hi

I don't want the path of current working directory. What i wanted is when we are uploading any image we browse that file from local machine say from c:\program files\mukesh.gif. so this path comes in input type file's text box. I want to get this path and wanted to show that image for preview purpose to user so that he/she can know what kind of image they are going to upload before uplaoding image in any html element like div or span.

if u need further clarification feel free to ask but please help me out
Apr 16 '09 #7
Dormilich
8,651 Expert Mod 8TB
@mukeshrasm
looks more like a job for JavaSript (kind of validation). once you submit the form, you have already uploaded the image. it would be a waste of time and bandwidth if the user decides to not take this image.
Apr 16 '09 #8
mukeshrasm
254 100+
@Dormilich
before uploading image i want to show the preview of image
Apr 16 '09 #9
Dormilich
8,651 Expert Mod 8TB
you can use Javascript to get the path from the input field (field.value), create an <img> and pass this value to the src attribute.
Apr 16 '09 #10
mukeshrasm
254 100+
@Dormilich
I tried in this way

Expand|Select|Wrap|Line Numbers
  1.  function getimagefile ()
  2. {
  3.     var path= document.getElementById("imagepath").value
  4.     document.getElementById("getfile").src=path;//this works fine in ie but not in mozila firefox
  5.     //and I tried this as well but this not working in either ie or mozila 
  6.     document.getElementById("getfile").src = window.opener.document.getElementById("imagepath").innerText
  7. }
  8.  

Expand|Select|Wrap|Line Numbers
  1. <input type="file"  id="imagepath" name="mukesh" onchange="getimagefile()"/>
  2. <img id="getfile" src="" />
  3.  
  4.  
Apr 18 '09 #11
Dormilich
8,651 Expert Mod 8TB
a trial gave (FF 3.0.8, Mac OS 10.5.6)
- onchange didn't fire, so using onblur
- only filename was submitted
Apr 18 '09 #12
mukeshrasm
254 100+
@Dormilich
yes only filename was submitted in firefox and sorry I didn't get your a trial gave (FF 3.0.8, Mac OS 10.5.6)
Apr 18 '09 #13
hsriat
1,654 Expert 1GB
@mukeshrasm
This is not possible with JavaScript. But only "Java" can do this, like in Facebook image upload.
Apr 18 '09 #14
mukeshrasm
254 100+
@hsriat
but I am working in java and i am using php so how this will be done in php or javascript
Apr 18 '09 #15
Markus
6,050 Expert 4TB
@mukeshrasm
It is not possible in PHP, either. You have to upload the image first in order to access it.

A java applet will make it possible though, as said before.
Apr 18 '09 #16

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Ralph Freshour | last post: by
12 posts views Thread by Anders Eriksson | last post: by
1 post views Thread by Glenn Coyle | last post: by
4 posts views Thread by ish | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.