file uploading
Moderator: General Moderators
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
file uploading
is there anyway to upload a file using PHP and name it what i want then ad the path to a database?
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
Create the upload by using:
<input type="file" name="filename">
and create another field like this:
<input type="text" name="newname">.
Change the temp upload path to your temp folder, and your new name path to the place you want the file to be.
Just-like-this:
Hope that's what you need!
<input type="file" name="filename">
and create another field like this:
<input type="text" name="newname">.
Change the temp upload path to your temp folder, and your new name path to the place you want the file to be.
Just-like-this:
Code: Select all
<?php
function do_upload($filename,$newname) {
$file = basename($filename);
$tmp_upload_path = "c:\\apache\\htdocs\\tmp"e;;
$new_file_name = "c:\\apache\\upload"e;.$newname;
if (!copy($tmp_upload_path.$file, $new_file_name)) echo "failed to copy file<br>\n";
return;
}
?>