Copy link to clipboard
Copied
Hi there,
I have a form that saves data to a MySQL db. In this form there are four input type file to upload images.
Everything is made with the Dreamweaver wizard.
What I need to do is to store the file path into MySQL and the file into a folder of the website.
I assume that I need to change in GetSQLValueString($_POST['variable'], "text"), but I don't know how to do it.
Anyone can help???
Thank you VERY mcuh
Jaume
Can this be done with dreamweaver????
That is not the question. You should ask "Can this be done with PHP", and the answer is yes, sure. Google "PHP image resize" - you'll find lots....
Copy link to clipboard
Copied
And you're sure you added the enctype? Can we see your entire page again?
Copy link to clipboard
Copied
Ok Here it is below. The online development version is here http://netdataflow.com/rbme/addprojectreview.php
<fieldset>
<legend>Review & Submit</legend>
<form id="submitpage" name="submitpage" method="POST" enctype="multipart/form-data" action="<?php echo $editFormAction; ?>">
<div align="center">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><strong>Core Project Details</strong></td>
</tr>
<tr id="rowlines">
<td width="235"><p>Project Code:
<input name="projcode" type="text" id="projcode" value="<?php echo $_POST['projcode']; ?>" />
</p></td>
<td width="265"><p>
<label for="projcode"></label>
Project Name:
<input name="projname" type="text" id="projname" value="<?php echo $_POST['projname']; ?>" />
</p></td>
</tr>
<tr id="rowlines">
<td colspan="2"><p>Project Description:<span id="description"></span></p> <p>
<label for="projdesc"></label>
<textarea name="projdesc" id="projdesc" cols="60" rows="8"><?php echo $_POST['projdesc']; ?></textarea>
</p></td>
</tr>
<tr id="rowlines">
<td><p>Project Year:
<input name="projdateentered" type="text" id="projdateentered" value="<?php echo $_POST['projdateentered']; ?>" />
</p></td>
<td><p>Project LGA:
<input name="projlga" type="text" id="projlga" value="<?php echo $_POST['projlga']; ?>" />
</p></td>
</tr>
<tr id="rowlines">
<td><p>Project Community:
<input name="projcommunity" type="text" id="projcommunity" value="<?php echo $_POST['projcommunity']; ?>" />
</p></td>
<td><p>Project State:
<input name="projstate" type="text" id="projstate" value="<?php echo $_POST['projstate']; ?>" />
</p></td>
</tr>
<tr id="rowlines">
<td colspan="2"><p>Project Baseline Data:</p> <p>
<textarea name="projbaselinedata" id="projbaselinedata" cols="60" rows="8"><?php echo $_POST['projbaselinedata']; ?></textarea>
</p></td>
</tr>
<tr id="rowlines">
<td colspan="2"><p>Expected Outcome Of Project:</p> <p>
<textarea name="Projexpoutcome" id="Projexpoutcome" cols="60" rows="8"><?php echo $_POST['Projexpoutcome']; ?></textarea>
</p></td>
</tr>
<tr id="rowlines">
<td><p>Project Cost:
<input name="projcost" type="text" id="projcost" value="<?php echo $_POST['projcost']; ?>" />
</p></td>
<td><p>
Project Type:
<input name="projtype" type="text" id="projtype" value="<?php echo $_POST['projtype']; ?>" />
</p></td>
</tr>
<tr>
<td colspan="2"><strong>Beneficiaries</strong></td>
</tr>
<tr id="rowlines">
<td><p>Adult Men Beneficiaries:
<input name="adultmen" type="text" id="adultmen" value="<?php echo $_POST['adultmen']; ?>" />
</p></td>
<td><p>Adult Female Beneficiaries:
<input name="adultfem" type="text" id="adultfem" value="<?php echo $_POST['adultfem']; ?>" />
</p></td>
</tr>
<tr id="rowlines">
<td><p>Adult Children Beneficiaries:
<input name="totalchildren" type="text" id="totalchildren" value="<?php echo $_POST['totalchildren']; ?>" />
</p></td>
<td><p>Total Beneficiaries:
<input name="totalben" type="text" id="totalben" value="<?php echo $_POST['totalben']; ?>" readonly="readonly" />
</p></td>
</tr>
<tr>
<td colspan="2"><strong>Project Team</strong></td>
</tr>
<tr id="rowlines">
<td><p>Project Team Leader:
<input name="projteamlead" type="text" id="projteamlead" value="<?php echo $_POST['projteamlead']; ?>" />
</p></td>
<td><p>Deputy Team Leader:
<input name="projdepteamlead" type="text" id="projdepteamlead" value="<?php echo $_POST['projdepteamlead']; ?>" />
</p></td>
</tr>
<tr id="rowlines">
<td><p>Project Officer:
<input name="projofficer" type="text" id="projofficer" value="<?php echo $_POST['projofficer']; ?>" />
</p></td>
<td><p>Liason Officer:
<input name="projliasonofficer" type="text" id="projliasonofficer" value="<?php echo $_POST['projliasonofficer']; ?>" />
</p></td>
</tr>
<tr>
<td colspan="2"><strong>Meeting Dates</strong></td>
</tr>
<tr id="rowlines">
<td><p>First Project Meeting Date:
<input name="projmeeting1" type="text" id="projmeeting1" value="<?php echo $_POST['projmeeting1']; ?>" />
</p></td>
<td><p>Third Project Meeting Date:
<input name="projmeeting3" type="text" id="projmeeting3" value="<?php echo $_POST['projmeeting3']; ?>" />
</p></td>
</tr>
<tr id="rowlines">
<td><p>Second Project Meeting
Date:
<input name="projmeeting2" type="text" id="projmeeting2" value="<?php echo $_POST['projmeeting2']; ?>" />
</p></td>
<td><p> </p></td>
</tr>
<tr>
<td colspan="2"><strong>Other Dates</strong></td>
</tr>
<tr id="rowlines">
<td><p>Project Start Date:
<label for="projstartdate"></label>
<input name="projstartdate" type="text" id="projstartdate" value="<?php echo $_POST['projstartdate']; ?>" />
</p></td>
<td><p>MoU Signing Date:
<input name="projmousigndate" type="text" id="projmousigndate" value="<?php echo $_POST['projmousigndate']; ?>" />
</p></td>
</tr>
<tr id="rowlines">
<td><p>Project End Date:
<label for="projstartdate"></label>
<input name="projenddate" type="text" id="projenddate" value="<?php echo $_POST['projenddate']; ?>" />
</p></td>
<td><p> </p></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr id="moredetails">
<td colspan="2" id="moredetails"><strong>Upload Initial Project Documents/Pictures</strong></td>
</tr>
<tr>
<td id="formcells"><p>Document/Picture One:
<label for="Projdoc1"></label>
<input type="file" name="Projdoc1" id="Projdoc1" />
</p></td>
<td id="formcells"><p>Document/Picture Four:
<label for="Projimg1"></label>
<input type="file" name="Projimg1" id="Projimg1" />
</p></td>
</tr>
<tr>
<td id="formcells"><p>Document/Picture Two:
<label for="Projdoc2"></label>
<input type="file" name="Projdoc2" id="Projdoc2" />
</p></td>
<td id="formcells"><p>Document/Picture Five:
<label for="Projimg2"></label>
<input type="file" name="Projimg2" id="Projimg2" />
</p></td>
</tr>
<tr>
<td id="formcells"><p>Document/Picture Three:
<label for="Projdoc3"></label>
<input type="file" name="Projdoc3" id="Projdoc3" />
</p></td>
<td id="formcells"><p>Document/Picture Six:
<label for="Projimg3"></label>
<input type="file" name="Projimg3" id="Projimg3" />
</p></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
<p>
<input type="submit" name="btn_submit" id="btn_submit" value="Save & Submit" />
</p>
</div>
<!-- end .content -->
<input type="hidden" name="MM_insert" value="submitpage" />
</form>
</fieldset>
Copy link to clipboard
Copied
To try the online version of the web application please begin from the Project Core Details which has the link http://netdataflow.com/rbme/addprojectcore.php
The site login details are provided by default
Thank you
Mike
Copy link to clipboard
Copied
The code in the online version does not match what you posted. For example, the form tag online is:
<form id="submitpage" name="submitpage" method="POST" action="/rbme/addprojectreview.php?">
Are you uploading your page to the correct location? Is your upload failing?
Copy link to clipboard
Copied
I am sorry. The online version has been updated now with the current codes
Mike
Copy link to clipboard
Copied
I'm getting an "Unknown column 'Projdoc1' in 'field list'" . Check your database table and make sure a column of that name exists. Make sure it is spelled exactly the same.
Copy link to clipboard
Copied
Hi Bregent,
Thank you for the observation. I am really sorry for that aswell. The Project table is now updated.
Please try again.
Mike
Copy link to clipboard
Copied
Please indicate which fields are mandatory. There are too many fields we need to fill in to test this. It would be helpful if you could modifify the form to include some default sample data, so we can test and see the results. Is there still an error message?
As an aside, your form needs to include better validation that would allow the user to go back and fill in incorrect fields. As it is now, all of the fields are cleared when going back after recieving the server side error message.
Copy link to clipboard
Copied
Hi Bregent,
Thank you for your response.
Specifically all fields are required except the upload fields but based on your request I have added defaults values. Now only the fields with marked with asterisks by the label are compulsory. The dates fields are easy to fill as they have date picker in them. Once you click the date picker widget will pop up. The list/menu fields are easy to fill.
With regards on the seconds paragraph "As an aside, your form needs to include better validation that would allow the user to go back and fill in incorrect fields. As it is now, all of the fields are cleared when going back after recieving the server side error message." , for now I dont know how to do this. What I did is make the last page called Review and Submit to be editable. Since its the last page, it shows the user all the entries and he can easily make changes before submitting the form. Is that a wrong method?
The errors are still there
Mike
Copy link to clipboard
Copied
OK, there are several things that are confusing. First of all, the 6 upload fields are labelled "Document/Picture One:", yet it appears that only 4-6 are setup to handle any type of attachment. Is this by design? Doesn't make sense to me.
Next, I don't really understand this:
$target = $target . basename( $_FILES['Projimg1']['name']);
$target = $target . basename( $_FILES['Projimg2']['name']);
$target = $target . basename( $_FILES['Projimg3']['name']);
You are concatenating 3 filenames together into the $target variable. How is that going to work? Unless I am not understanding something basic here, you probably need to create 3 target variables or just use basename( $_FILES['Projimg1']['name']); in the code as needed.
I'm not sure how much php experience you have, but unless you are skilled, this form and workflow is too complicated to troubleshoot as is. The final form has 600 lines of code and the php script is big too. Create a simpler one page form with fewer fields so you can test the basic functionality - file uploading - that you are attempting. Then you can incorporate it into your actual pages.
Copy link to clipboard
Copied
Hi Bregent,
Thank you once more. Actually I thought every thing will work from the beginning hence the 6 file uploads. Based on your advice I am going to remove the first 5 and work with only one and see how it goes. Once it works, I will now add one after the other to see.
With regards to this line of codes, was I supposed to write it this way for each fieldname:
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg1']['name']);
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg2']['name']);
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg3']['name']);
Instead of this other way that I earlier wrote it:
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg1']['name']);
$target = $target . basename( $_FILES['Projimg2']['name']);
$target = $target . basename( $_FILES['Projimg3']['name']);
On the area of Php skill, this is actually my first major project using PHP. Thanks to Dreamweaver.
Thank you.
Mike
Copy link to clipboard
Copied
Hi Bregent,
Thank you once more. Actually I thought every thing will work from the beginning hence the 6 file uploads. Based on your advice I am going to remove the first 5 and work with only one and see how it goes. Once it works, I will now add one after the other to see.
With regards to this line of codes, was I supposed to write it this way for each fieldname:
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg1']['name']);
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg2']['name']);
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg3']['name']);
Instead of this other way that I earlier wrote it:
$target = $_SERVER['DOCUMENT_ROOT'] . "/uploads/"; //This is the directory where images will be saved//
$target = $target . basename( $_FILES['Projimg1']['name']);
$target = $target . basename( $_FILES['Projimg2']['name']);
$target = $target . basename( $_FILES['Projimg3']['name']);
On the area of Php skill, this is actually my first major project using PHP. Thanks to Dreamweaver.
Thank you.
Mike
Copy link to clipboard
Copied
>With regards to this line of codes, was I supposed to write it this way for each fieldname:
Either way would yield the same, faulty results. The $target variable is used in several place in your code and used to specify the destination path/filename. You can't concatenate all 3 of the path/filenames into a single variable. You need to create 3 variables and replace their occurrence accordingly within your code:
$target1
$target2
$target3
There are probably more elegant ways of doing this, but start with that for now.
Copy link to clipboard
Copied
Hi Bregent,
How are you doing?
I have successfully resolved the image upload issue. Infact I am able to upload as much as 6 images at the same time and populate them on a read only page based on the ID of the project name that is selected. This is a complete new method from the one I was using before now.
You can take a look by login into our demo site http://www.netdataflow.com/rbme/
1. When you are at the home page, http://www.netdataflow.com/rbme/index.php,
2. Click on My Projects and then at the top right click on Add New Project
3. Fill the form as usual with the default details. For project name, please enter one as I have made it unique to avaoid double entry.
4. When you are done, you will presented with a new page where you can upload one or two images. This is the last entry page
5. When you are done please go back to My Project page and click on the project you just added. This should be the last on the list. There you will see the picture.
Please kindly advice on my performance.
Thank you in advance
Mike
Copy link to clipboard
Copied
When I am done with the entire project, I will encrypt the pages before uploading them to the production site