Hi,
Ive created a registration page in which at the last it asks the user to upload the resume file. When the user clicks on the upload button to upload the file it automativcally submits all the data entered in the form. I want that when the user uploads the file after clicking the upload button it should display the message of successful upload on the same page itself. Then when the user clicks on the submit button the data should be entered in the database.
Ive attached the registration form file plz let me know how i can fix this problem.
I ve given the required code below.
[code=php]
<tr>
<td bgcolor="#ECE9D 8"> <div align="center">
<span class="style14" >
<input type="hidden" name="MAX_FILE_ SIZE" value="8000000" >
Select file: </span>
<input type="file" name="data">
<input type="submit" name="Submit" value="Upload File">
</div>
</td>
</tr>
<tr>
<td height="38" bgcolor="#ECE9D 8"><div align="center">
<input name="Reset" type="reset" id="Reset" value="Reset" />
<input type="submit" name="Submit" value="Submit" />
</div></td>
</tr>
</form>
<?php
} else {
// check uploaded file size
if ($_FILES['data']['size'] == 0) {
die("ERROR: Zero byte file upload");
}
// check if file type is allowed (optional)
$allowedFileTyp es = array("text/plain", "applicatio n/msword");
if (!in_array($_FI LES['data']['type'], $allowedFileTyp es)) {
die("ERROR: File type not permitted");
}
// check if this is a valid upload
if (!is_uploaded_f ile($_FILES['data']['tmp_name'])) {
die("ERROR: Not a valid file upload");
}
// set the name of the target directory
$uploadDir = "./uploads/";
// copy the uploaded file to the directory
move_uploaded_f ile($_FILES['data']['tmp_name'], $uploadDir .$_FILES['data']['name']) or die("Cannot copy uploaded file");
// display success message
echo "File successfully uploaded. " ;
}
[/code]
Ive created a registration page in which at the last it asks the user to upload the resume file. When the user clicks on the upload button to upload the file it automativcally submits all the data entered in the form. I want that when the user uploads the file after clicking the upload button it should display the message of successful upload on the same page itself. Then when the user clicks on the submit button the data should be entered in the database.
Ive attached the registration form file plz let me know how i can fix this problem.
I ve given the required code below.
[code=php]
<tr>
<td bgcolor="#ECE9D 8"> <div align="center">
<span class="style14" >
<input type="hidden" name="MAX_FILE_ SIZE" value="8000000" >
Select file: </span>
<input type="file" name="data">
<input type="submit" name="Submit" value="Upload File">
</div>
</td>
</tr>
<tr>
<td height="38" bgcolor="#ECE9D 8"><div align="center">
<input name="Reset" type="reset" id="Reset" value="Reset" />
<input type="submit" name="Submit" value="Submit" />
</div></td>
</tr>
</form>
<?php
} else {
// check uploaded file size
if ($_FILES['data']['size'] == 0) {
die("ERROR: Zero byte file upload");
}
// check if file type is allowed (optional)
$allowedFileTyp es = array("text/plain", "applicatio n/msword");
if (!in_array($_FI LES['data']['type'], $allowedFileTyp es)) {
die("ERROR: File type not permitted");
}
// check if this is a valid upload
if (!is_uploaded_f ile($_FILES['data']['tmp_name'])) {
die("ERROR: Not a valid file upload");
}
// set the name of the target directory
$uploadDir = "./uploads/";
// copy the uploaded file to the directory
move_uploaded_f ile($_FILES['data']['tmp_name'], $uploadDir .$_FILES['data']['name']) or die("Cannot copy uploaded file");
// display success message
echo "File successfully uploaded. " ;
}
[/code]
Comment