Issue with POST upload

I have a form that is submitting photo filepath to database on top of some other text. When I submit the form it only show blank page and I’m not sure where it is going wrong

Here is the form…

[php]
Step 1. Choose a picture:









Step 2. Enter a caption for the image





Step 3. Judg whatever/whoever is in that picture:





(Maximum characters: 350)

You have characters left.

        <input type="hidden" name="url" value='<?php echo "Date:".date('Y-m-d H:i:s')."<br />Ip:".$_SERVER['REMOTE_ADDR'].""?>'/>
      <label for="submit"><span class="steps">Step 4.</span> Submit it:</label>         
        <br>
        <input name="upload" type="submit" id="upload" value="JUDGD!"/>
    </form>[/php]

And here is the upload script

[php]<?php include ‘db.php’;
$uploadDir = ‘uploaded_images/’; //Folder name for uploaded images

$limitedtextarea = addslashes(urldecode($_POST[‘limitedtextarea’])); //The actual judgment
$url = addslashes(urldecode($_POST[‘url’])); //URL (not yet implemented)
$figcaption = addslashes(urldecode($_POST[‘figcaption’])); //Caption for the image

//I believe the error begins here|/

if(isset($_POST[‘upload’]))
{

$fileName = $_FILES[‘userfile’][‘name’];
$tmpName = $_FILES[‘userfile’][‘tmp_name’];
$fileSize = $_FILES[‘userfile’][‘size’];
$fileType = $_FILES[‘userfile’][‘type’];

$image = $fileType;

$filePath = $fileName; //file path for inserting into database ex. image_name.jpg

$result = move_uploaded_file($tmpName,$uploadDir . $filePath); //file path for uploading to folder ex. uploaded_images/image_name.jpg
if (!$result) {
include ‘something_went_wrong.php’;
exit;
}

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
else {
echo “error”;
}

$query = “INSERT INTO judgment (limitedtextarea, name, size, type, path, url, figcaption )
VALUES (’$limitedtextarea’,’$fileName’, ‘$fileSize’, ‘$fileType’, ‘$filePath’, ‘$url’, ‘$figcaption’)”;

mysql_query($query) or die('Error, query failed : ’ . mysql_error());

if($result){
include ‘judgment_posted.php’;
}
else {
include ‘something_went_wrong.php’;
}
}
?>[/php]

try removing the

[php]exit; [/php]

Sorry

Was that the problem ?

Didn’t work still…

Have you got anything that says its done ?

maybe this page is the problem ?
[php] include ‘judgment_posted.php’;
echo ‘posted’;

[/php]

Maybe add an echo thank you at the end

There are no errors, just blank page

sorry my mistake you have the submit named as upload

Is the file moved to the right place ?
[php]
if (file_exists ($uploadDir . $filePath)){
echo ‘result is true’;
}
[/php]

I believe the issue is somewhere in here

[php]if(isset($_POST[‘upload’]))
{

$fileName = $_FILES[‘userfile’][‘name’];
$tmpName = $_FILES[‘userfile’][‘tmp_name’];
$fileSize = $_FILES[‘userfile’][‘size’];
$fileType = $_FILES[‘userfile’][‘type’];

$image = $fileType;

$filePath = $fileName; //file path for inserting into database ex. image_name.jpg

$result = move_uploaded_file($tmpName,$uploadDir . $filePath); //file path for uploading to folder ex. uploaded_images/image_name.jpg
if (!$result) {
include ‘something_went_wrong.php’;
}[/php]

can you tell me is the value of the file has been posted echo $_POST[‘userfile’];

[php]if( isset($_POST[‘userfile’])){
echo 'upload = '.$_POST[‘userfile’];
} else{
echo ‘not set need posted upload value’;
}[/php]

Nothing is returned…

Did you put it at the top of the judgd_post.php page ?

and did you remove the exit;?

not set need posted upload value

remove this from the form

 enctype="multipart/form-data"

Do you get a value now ?

put this at the top instead sorry
is the array correct
[php]print_r($_FILES);[/php]

I tested the code seems to work fine.

Is there anything in your responce files that you include ?
Maybe post them.

it prints out

[php]Array()[/php]

Sorry you will have to put this back in the form again.

[php]enctype=“multipart/form-data”[/php]

Same outcome… Array()

Strange but the form does not seem to be posting the file.

Do you get the image uploaded ?

Put at the top of the php page
[php]ini_set(‘display_errors’, ‘1’);[/php]

Without the input userfile being posted nothing will work but you should get some sort of error.
Rather than include a file for errors just put echo for the error messages add a number to ones that have more than one of the same error message, or something that tell you which part it got to before breaking.
[php]
echo ‘good’;
echo ‘bad’; [/php]

When you get th epost right you will get somethign like this instead of array{}

[php]array(1) { [“userfile”]=> array(5) { [“name”]=> string(12) “finished.jpg” [“type”]=> string(11) “image/pjpeg” [“tmp_name”]=> string(26) “G:\Server5\tmp\php3843.tmp” [“error”]=> int(0) [“size”]=> int(144756) } } [/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service