0

Apologies if this is a duplicate question it just seems that every article i visit doesnt work for me. I have a basic form which has two fields and a file.

<form action="make_announce.php" method="post" enctype="multipart/form-data" data-ajax="false">
<label>Enter Subject Line (500char max):
<input name="subject" type="text" id="subject" size="50"/></label>

<label>Announcement :
<textarea name="announce" cols="50" rows="10" id="announce"></textarea></label>

<label>Post Image (Leave Blank for NONE)<br>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input type="file" name="image" /><br /></label>

<div align="center">
<input type="submit" name="Submit" value="OK" />
</div>
</form> 

And my PHP File minus most of the variables.

if (!empty($_FILES["image"])) {
    $myFile = $_FILES["image"];

    if ($myFile["error"] !== UPLOAD_ERR_OK) {
        $sql="...
        mysqli_query($con,$sql);
    exit;
    }
    $name = preg_replace("/[^A-Z0-9._-]/i", "_", $myFile["name"]);
    $i = 0;
    $parts = pathinfo($name);
    while (file_exists(UPLOAD_DIR . $name)) {
        $i++;
        $name = $parts["filename"] . "-" . $i . "." . $parts["extension"];
    }
    $success = move_uploaded_file($myFile["tmp_name"],
        UPLOAD_DIR . $name);
    if (!$success) { 
    $sql="...
mysqli_query($con,$sql);
    exit;
    }
    else
    {
    chmod(UPLOAD_DIR . $name, 0644);
    $sql="...
    mysqli_query($con,$sql);
    exit;
    }


}
mysqli_close($con);

Although this may not be the best way to do this it does work fine on a basic php web page. however when i put it into a jquery mobile web page it again works but doesnt seem to be posting the file im uploading. even after finding lots of articles telling me to add the data-ajax="false" to my form.

Any help would be very much appreciated. Thanks in advance.

1 Answer 1

1

Turn off Ajax navigation using data-ajax="false" on your form definition because you can't upload files using Ajax.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.