Jump to content

[SOLVED] Php upload script


jandrews3

Recommended Posts

I'm having difficulty with an upload script. I want the script to upload the file and save it in the "documents" folder using the actual name of the file. I can get it to work ONLY IF I place a VALUE="<?print $version?>" in the form (given that the variable $version is pre-assigned). Otherwise no value gets passed with $version. I provided 2 chunks of code: the upload script and then the handler. THANKS!

<form action="uploader_b.php" method="post" enctype="multipart/form-data" style="margin-bottom: 0;">
  <input type="file" name="file">
  <input type="hidden" name="version">
  <input type="submit" value="Upload File">
</form>

and


if ($file_name !="")
{
	if ($photo != ""){$file_name = $version.".pdf";}
	else {$file_name = $version.".pdf";}
	copy ("$file", "documents/$file_name")
		or die("Could not copy file");
}
else { die("No file specified"); }

$filename = $file_name;


print $file_name."<br>";
print $version."<br>";
print $file."<br>";

 

Link to comment
https://forums.phpfreaks.com/topic/124753-solved-php-upload-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.