如何在上传文件的同一路径中保存文件,PHP?

Use PHP , my concept is: User upload image by submit form, then script overlay logo watermark. I want to save the modified image to the same location of original image (on user's computer). My code now is something like this:

<form name="form1" method="post" action="watermark.php" enctype="multipart/form-data">

Select file:
<input type="file" name="uploadfile"/>
<input type="submit" value="submit">

</form>

How to know the path of original file to save the modified image in the same location?

You can't save it directly on user's computer (using HTML) as that would be a violation of - everything. Instead, you can provide the file for download after modification. Provided, you are using GD for watermarking, the code is simple (but not perfect and should be considered just a lead):

// perform some ops with $img

Header('Content-Type: image/jpeg');
Header('Content-Disposition: attachment; filename=' . $filename);

imagejpeg($img);

imagedestroy($img);

Its easy. I have done that. When the user uploads the images, instead of just taking the images, create a hidden field to store the whole path. Now, either leave this path on user's PC in cookie or store it with you. At the time to returning, use the customized save as dialog box and insert that path before the file.