Patrice_K: Hilfe PHP Pictureuploadanpassung

Hallo zusammen,
ich bin weder Informatiker noch sonst gross technisch begabt, habe aber donnoch die Aufgabe vom Chef bekommen bei einer PHP Image Upload Seite sie so anzupassen, dass wenn man auf "Durchsuchen" klickt und dann ein Bild auswählt, welches später heraufgeladen wird, direkt mit diesem Namen dann auch in die Datenbank abgespeichert wird.
Beim jetzigen Script muss man in ein saparates Feld Namen eingeben.
Dh. das File kann lokal Hans.jpg heissen, aber wenn man in diesem separatem Feld Peter.jpg eingibt, wird es unter Peter.jpg gespeichert.

Kann mir jemand helfen dieses separate Feld wegzumachen und dann anschliessen sagen, was ich machen kann, dass der Imagename automatisch übernommen wird???

Hier die Scripts...

1.Seite mit dem den Eingabefeldern usw:

<br>
<title> CLCM Database</title><body bgcolor="#E7B725">
<form name="form2" method="post" enctype="multipart/form-data" action="picupload.php">
<?php include ("menu.php"); ?><map name="Map7">
<area shape="rect" coords="0,1,156,23" href="eingabemaske.php">
</map>
<map name="Map11">
<area shape="rect" coords="0,0,102,23" href="type.php">
</map>
<map name="Map12">
<area shape="rect" coords="1,1,133,23" href="producer.php">
</map>
<map name="Map13">
<area shape="rect" coords="2,1,104,24" href="user.php">
</map>
<map name="Map10">
<area shape="rect" coords="1,0,314,27" href="change_details.php">
</map>
<strong>
<map name="Map9">
<area shape="rect" coords="0,1,312,27" href="add_data.php">
</map>
</strong>
<map name="Map8">
<area shape="rect" coords="1,1,190,26" href="add_comment_url.php">
</map>
<br>

<table width="80%" border="0" align="center">
<tr>
<td height="24"><div align="center"><strong><font size="5" face="Verdana">Add
Picture to Standard:</font></strong></div></td>
</tr>
</table>
<br>
<table width="50%" border="0" align="center">
<tr>
<td>If you do have a Picture for this device you are able to upload it here</td>
</tr>
<tr>
<td><p>Use browse button and enter the new name of the file without extension
in the second field.<br>
</p></td>
</tr>
<tr>

</tr>
</table>
<table width="50%" border="0" align="center">
<tr>
<td width="31%" height="21" bgcolor="#FF6600">Upload a Picture </td>
<td width="69%">
<input type="file" name="uploadedfile" size="30"> </td>
</tr>
<tr>

<td height="21"> </td>
<td><input type="text" name="picname" value="">
<input type="hidden" name="max_file_size" value="100000"> <input type="hidden" name="func" value="two">
<input type="hidden" name="id2" value="<?php print "$id"; ?>">
<input type="hidden" name="time" value="<?php //definition of momental time and date
$ret= time(); print gmdate ("F, d Y H:i" ); ?>">
<input type="submit" value="Send"></td>

</tr>
</table>

<table width="70%" border="0" align="center">
<tr>
<td><div align="center">Please consider that it is not possible to add more
than one picture for each device.</div></td>
</tr>
</table>
<p> </p>
</form>
<map name="Map">
<area shape="rect" coords="1,1,77,27" href="bye.php">
</map>
<map name="Map2">
<area shape="rect" coords="1,1,31,38" href="bye.php">
</map>

2.Seite

<title>CLCM Database</title><body bgcolor="#E7B725">
<?php

//____________________________________________
//START OF CONFIGURATION
//____________________________________________
//relative path from this script to folder where images must upload
$dir='../pictures';
//apsolut URL path from begin of your site
$apsolut_dir="http://informatics.roche.com/pictures";
//____________________________________________
//END OF CONFIGURATION
//____________________________________________

//begin of code
if (!$func) {
$func = "one";
}
switch ($func) {
case one:

break;

case two:
//collect the name from POST VARS
$ime="{$HTTP_POST_VARS['picname']}";
//get type of file
$ekst=$uploadedfile_type;
//get lenght of image type
$duzina=strlen($ekst);
//get part of file image to build image extension
$pos=strpos($ekst,"/")+1;
//build extension of image
$ekstenzija=substr($ekst,$pos,$duzina);
//correct errors with some images
//jpg
if($ekstenzija=="pjpeg"){
$ekstenzija="jpg";
}
//png
if($ekstenzija=="x-png"){
$ekstenzija="png";
}
//wmf
if($ekstenzija=="x-wmf"){
$ekstenzija="wmf";
}
//psd
if($ekstenzija=="octet-stream"){
$ekstenzija="psd";
}
//added in version 0.2
//if the name is empty copy name of image from your HDD
//that correct error if you do not enter new name of image
if (!$ime)
{
$ime=$uploadedfile_name;
}
//build new name of name that you specified, . and extension of image
else {
$ime.=".".$ekstenzija;
}
//if image exist, upload it in correct dir and save to database
$pic="http://informatics.roche.com/clcm/pictures/".$ime;

//connect include
include ("connect.php");

//Insert Data into table....

$s= OCIParse ($c, "UPDATE TBL_STANDARDS SET PIC='$pic' WHERE ID='$id2'");
OCIExecute ($s, OCI_DEFAULT);

//insert data into tbl_time to enter the date and time from this moment
$s2= OCIParse ($c, "UPDATE TBL_TIME SET TIME='$time'");
OCIExecute ($s2, OCI_DEFAULT);

//commit to save changes...

OCICommit ($c);

if($uploadedfile<>"none") {
if(!copy($uploadedfile,"$dir/$ime"))
{
//display errors
print("Error: image did not send.<br>");
print("Image is too big or it does not exist.<br>");
print("Try again.");
}
//or finish

else {

//output
print("Image has been sent.<br><small>image location on server is: $apsolut_dir/$ime</small>");
}
}
break;

}
?>
<form name="form1" method="post" action="add_data.php">
<input type="submit" name="Submit" value="go back to add more pictures">
</form>

  1. Hi,

    zunächst mal der dezente Hinweis auf FAQ Q-07c (zweiter Absatz).

    Kann mir jemand helfen dieses separate Feld wegzumachen und dann anschliessen sagen, was ich machen kann, dass der Imagename automatisch übernommen wird???

    Feld weglassen:

      
    
    > <input type="text" name="picname" value="">  
    
    ~~~weglassen.  
      
    Automatisch übernehmen:  
    [$_FILES](http://fr.php.net/manual/de/features.file-upload.php#features.file-upload.post-method) angucken.  
      
    HIH,  
    Der Yeti
    
    -- 
    Habe nun, ach! [WInfo](http://www.informatik.uni-koeln.de/winfo/), BWL, und Mathe, Und leider auch Info!  
    Durchaus studiert, mit heißem Bemühn. Da steh' ich nun, ich armer Thor!  
    Und bin so klug als wie zuvor!  
      
    [sh:( fo:| ch:? rl:? br:< n4:& ie:( mo:| va:| de:\[ zu:) fl:| ss:) ls:< js:|](http://community.de.selfhtml.org/fanprojekte/selfcode.htm)