Click to See Complete Forum and Search --> : Plz hlp
katasova
02-15-2006, 12:41 PM
Hello, I have this doubt:
I have an string saved in a variable $x this string is the path to a directory, lets say:
$x = "c:\file.gif";
Now my question is, can i apply the $_FILES propertys to this string in order to play with this file (upload, erase, change name...)?
Or how should i define a variable to do it? I just dont wanna have to pass the file from html or javascript...
THX
bokeh
02-15-2006, 02:17 PM
You need to explain your question better.
Wisest Guy
02-15-2006, 02:36 PM
Why do you need that file in the $_FILES array?
katasova
02-15-2006, 02:36 PM
hehe yeah i guess.... ok i will say waht i want to do.
$file = "c:/file.gif";
//this is if i get the file from html but im not getting the path from html cause i define it in $file
//$tmpName = $_FILES['archivo']['tmp_name'];
//$fileSize = $_FILES['archivo']['size'];
//$fileType = $_FILES['archivo']['type'];
$filePath = "whatever....";
move_uploaded_file($tmpName, $filePath);
So, how can i upload a file that i specify inside PHP not from html.
i hope i made myself more clear this time :D
NogDog
02-15-2006, 03:25 PM
You cannot upload a file from the client via a script on the server - that would be a very serious security hole. All you can do is provide a form to the user with a <input type="file"> element to allow them to upload a file if they so desire, then handle that upload via the script called by the HTML form. You can set a default value for the file element:
<input type="file" name="upload" value"c:\file.gif">
Wisest Guy
02-16-2006, 02:35 PM
You could use javascript to submit the form, but I wouldn't want someone loading files from my computer.
bokeh
02-16-2006, 03:07 PM
<input type="file" name="upload" value="c:\file.gif">Sorry but you can't do that.
NogDog
02-16-2006, 03:48 PM
Sorry but you can't do that.
You can do it, and it's perfectly valid markup. As to whether any browsers support it, that's another question. :rolleyes:
From http://www.w3.org/TR/html4/interact/forms.html#h-17.4
[Type = ]file
Creates a file select control. User agents may use the value of the value attribute as the initial file name.
bokeh
02-16-2006, 04:36 PM
You can do it, and it's perfectly valid markup. As to whether any browsers support it, that's another question. :rolleyes:
From http://www.w3.org/TR/html4/interact/forms.html#h-17.4Sorry my answer was vague. I wasn't implying it was not valid code just that it wont work. If it did it would be a major security hole. One would be able to send forms to clients with a file path prefilled and then use javascript to autosubmit them.
SpectreReturns
02-16-2006, 07:19 PM
I'm going to run along and see if I can get that working. I'll post a link if I do.
welsh
02-16-2006, 07:22 PM
if u got it working and it uploaded a file from us why would we click it!!!!
SpectreReturns
02-16-2006, 07:27 PM
Because I'm the kind of guy who would make it upload a file like "C:/filetoupload.txt", and tell you if that file wasn't present on your computer. Plus, the point is moot. All of my browsers (NS, IE, FX) provide only read access in javascript and html to file..value.