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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.