Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 201283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:11:08+00:00 2026-05-11T17:11:08+00:00

I am using this form as a file upload form(as part of a larger

  • 0

I am using this form as a file upload form(as part of a larger php script, $pk is sanitized in the actual thing):

<?php

if (isset($_GET["pk"]))
 { $pk = $_GET["pk"];}
echo '<form action="up.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<input type="hidden" name="pk" value="$pk">
<br />
<input type="submit" name="submit" value="Submit" />
</form>';
?>

I am using the following(extremely trimmed) code to handle the upload. Any syntax errors are a result of the tabifier I used.

<?php
 if (isset($_GET["pk"])) {
    $pk = $_GET["pk"];
}
$con = mysqli_connect("localhost","x","x", "x");
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
move_uploaded_file($_FILES["file"]["tmp_name"],
      "./" . $_FILES["file"]["name"]);
echo "Stored in: " . "./" . $_FILES["file"]["name"];
$fileQuery = "INSERT INTO FILES VALUES (?, ?)";
if ($fileInsert = $con->prepare($fileQuery)) {
    $fileInsert->bind_param("ss", $pk, $_FILES["file"]["name"]);
    $fileInsert->execute();
    $fileInsert->close();
} else {
    print_r($con->error);
}
?>

What I would like to know, is how do I access $pk. Is it already passed to the handling code with the form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:11:08+00:00Added an answer on May 11, 2026 at 5:11 pm

    Suggestion: $pk is not set.

    So try to use $_REQUEST['pk'] instead of _GET

    Also, the single quotes in your echo won’t evaluate $pk. Alter

    input type="hidden" name="pk" value="$pk"
    

    to

    input type="hidden" name="pk" value="' . $pk . '"
    

    Cheers, T.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this ViewScript for my standard form elements: <div class=field id=field_<?php echo
hii i am using ajax file upload in this code <script type=text/javascript src=fileuploader.js></script> <script
I am initializing file upload using the following HTML: <form enctype=multipart/form-data action=PHPScripts/upload.php method=POST> <input
I am writing a small file upload utility thing as part of a larger
I want to write a jQuery file uploading program, using this plug-in http://aquantum-demo.appspot.com/file-upload Despite
So I have ajax file upload partial (using Jquery Form plugin), it's working perfectly,
My PHP book gives a template HTML form for uploading a file: <form action=upload.php
I use this code for upload image: http://vikaskanani.wordpress.com/2011/01/11/android-upload-image-or-file-using-http-post-multi-part/ I replaced bm = BitmapFactory.decodeFile(/data/data/fshizzle.com/files/image.jpg); and
I'm trying to upload files via Pycurl through POST, using a PHP script on
I'm using Ext.Form.Panel successfully but I want to use Ext.form.field.File this time. I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.