Upload and Files tag
Moderator: General Moderators
Upload and Files tag
Hello
i'm trying to make an upload interface with php.
the problem is that i can't give a deffault value to the file tag
the generated code is :
<input type="file" name=fic_img size="11" value="img.jpg">
but the value don't appear in the page !!!
who can help me ?
thanks[/url]
i'm trying to make an upload interface with php.
the problem is that i can't give a deffault value to the file tag
the generated code is :
<input type="file" name=fic_img size="11" value="img.jpg">
but the value don't appear in the page !!!
who can help me ?
thanks[/url]
- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
i try to use this field for two thinks :
- modify an existing mission file
- create a new mission
in case of a new mission, i don't know what is the name of the field
in case of a existing mission, i know the default value
if the user just change the name of the mission, i have to keep the name of the image
if the user change the picture, i have to upload his picture !
i don't want to use two fields... if possible !!!
- modify an existing mission file
- create a new mission
in case of a new mission, i don't know what is the name of the field
in case of a existing mission, i know the default value
if the user just change the name of the mission, i have to keep the name of the image
if the user change the picture, i have to upload his picture !
i don't want to use two fields... if possible !!!
- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
Post your current code here. I'm really confused as to what's going on. I guess you are making some sort of game? Are you giving an option to upload a saved game file? Did you set up a database to keep this information?
Whatever you're trying to do, I'm completely certain that it can be done without needing a default value in the upload field, and would probably be better that way. Remember, an upload field takes the path of a file from the user's computer, such as "C:\gamefiles\mission2.msf" . If you don't know where the file is (you don't), there is no sense in putting a default value there.
Whatever you're trying to do, I'm completely certain that it can be done without needing a default value in the upload field, and would probably be better that way. Remember, an upload field takes the path of a file from the user's computer, such as "C:\gamefiles\mission2.msf" . If you don't know where the file is (you don't), there is no sense in putting a default value there.
I've got a mission database
-French Title
-French Object
-English Title
-Eng obj
-Spain Title
-Spain Object
-Image (a text field whis the name without the server path)
the administrator of the site can :
- create new mission
so I have to upload the file and to write the name in the Image field
- modify an existing mission
in this case, i want to put the default value because the administrator will perhaps change only the description and not the image !!!
i send you a part of the code :
or ($index = 1 ; $index < $nbcol ; $index++)
{
printf('<font color="'.$body_text2.'" size="'.$body_size.'" face="'.$body_font.'"><b>');
if ($mis[$index]<>"Image :") {
printf($mis[$index]." ".'</b></font><input type="text" name="'.$nom[$index].'" size="27" value="'.$lig[$index].'"> </font><br>');
}
else {
printf($mis[$index]." ".'</b></font><input type="text" name="'.$nom[$index].'" size="27" value="'.$lig[$index].'"> </font><br>');
printf('<font color="'.$body_text.'" size="'.$body_size.'" face="'.$body_font.'"><b>');
// HERE IS THE PROBLEM :
$temp="<input type=\"file\" name=".$nom[$index]." size=\"11\" value=\"".$lig[$index]."\">";
}
$fichier=$lig[$index];
THE GENERATED RESULT :
<input type="file" name="TXT_IMG" size="11" value="Unesco.jpg">
If you find something...
Thanks
Ax
-French Title
-French Object
-English Title
-Eng obj
-Spain Title
-Spain Object
-Image (a text field whis the name without the server path)
the administrator of the site can :
- create new mission
so I have to upload the file and to write the name in the Image field
- modify an existing mission
in this case, i want to put the default value because the administrator will perhaps change only the description and not the image !!!
i send you a part of the code :
or ($index = 1 ; $index < $nbcol ; $index++)
{
printf('<font color="'.$body_text2.'" size="'.$body_size.'" face="'.$body_font.'"><b>');
if ($mis[$index]<>"Image :") {
printf($mis[$index]." ".'</b></font><input type="text" name="'.$nom[$index].'" size="27" value="'.$lig[$index].'"> </font><br>');
}
else {
printf($mis[$index]." ".'</b></font><input type="text" name="'.$nom[$index].'" size="27" value="'.$lig[$index].'"> </font><br>');
printf('<font color="'.$body_text.'" size="'.$body_size.'" face="'.$body_font.'"><b>');
// HERE IS THE PROBLEM :
$temp="<input type=\"file\" name=".$nom[$index]." size=\"11\" value=\"".$lig[$index]."\">";
}
$fichier=$lig[$index];
THE GENERATED RESULT :
<input type="file" name="TXT_IMG" size="11" value="Unesco.jpg">
If you find something...
Thanks
Ax
- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
Ahh that's easy. Wherever you're sending this information, add a check for the file, something like:
Leaving the field blank will result in no change to the mission file.
Code: Select all
if ( $_FILESї'filename']ї'size'] != 0 )
{
// update the file
}- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
"file" fields work differently from other fields. They are meant for the user to enter the name of a file on thier computer, which the browser then sends to the server. The browser doesn't let you put a default value in, because it would be meaningless to everyone using it. Say you put the default value as "img.jpg" . If they press submit with that in there, no file would be sent, since there is not a file named "img.jpg" on their computer.
I hope you understand...
I hope you understand...