07-08-2011, 07:13 AM
Post the bit of code that is building the query.
07-08-2011, 07:59 AM
$query = "INSERT INTO properties ('location','description','image1','image2','image3','image4','image5','image6','image7','image8') VALUES ('$location','$description',";
foreach($active_keys as $key)
$query .= "'$_FILES[$fieldname]['name'][$key]',";
$query .= ")";
07-08-2011, 01:08 PM
Echo this query and check it for syntax
# Assuming image1, etc accept null values you could try something like this... Not tested
#set some variables
$query_part_1 = '';
$query_part_2 = '';
$i = 1;
foreach($active_keys as $key)
$query_part_1 .= ",'image" . $i++ . "'";
$query_part_2 .= ",'" . $_FILES[$fieldname]['name'][$key] . "'";
$query = "INSERT INTO properties ('location','description'" . $query_part_1 . ") VALUES ('" . $location . "','" . $description . "'" . $query_part_2 . ")";
Last edited by bokeh; 07-08-2011 at 01:11 PM.
07-08-2011, 04:12 PM
Query was perfect! Thanks so much Bokeh, you are a life saver!
10-06-2011, 02:28 PM
onchange event replace submit?
that did not help (I probably messed up) but I changed the name of the submit button to upload (When I use the onChange event, It doesn't seem to find the $_POST['upload'] variable
I have this if statement in upload.processor.php
But seems to see it if the submit button is clicked here
// check the upload form was actually submitted else print the form
or error('the upload form is neaded', $uploadForm);
Is that right? why doesnt the event act as if the submit button is clicked?
Let me explain what I'm trying to do as you might have a better way for me to do this...
I'm trying to upload an image the moment the onchange event is triggered so that the image in thumbnail size appears so that the upload is confirmed to the stupid, also how can this be done without refreshing the page as ill have another form on the page I dont want to reset?
Thanks a lot...
10-06-2011, 02:56 PM
Originally Posted by lukeurtnowski
05-26-2012, 08:27 AM
Hi, I was wondering if you could help me please? I've created a very basic CMS and would like to allow the site's administrator to upload some pre-named images eg. image1.jpg, image2.jpg. They then need to be able to add them to pages using a form. I've set all of this up and they can add text with no problems. I would like them to be able to insert images into the pages by using <img src="image1.jpg" /> etc but this won't work due to the long string of numbers added to the image, as referred to in post #68. From reading further posts I understand that this relates to the date and time of upload and comes from the following lines of code:
// make a unique filename for the uploaded file and check it is
// not taken... if it is keep trying until we find a vacant one
$now = time();
while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name']))
// now let's move the file to its final and allocate it with the new filename
or error('receiving directory insuffiecient permission', $uploadForm);
Now, I am a complete numpty at php and was wondering if you could please tell me EXACTLY what code I need to remove (or add) to fix the issue as I can't figure this out myself? I have tried and it's probably very simple and obvious when you know what you're doing but I can't get it to work.
05-26-2012, 09:39 AM
That code was just an example of one way to name a file so there weren't collisions. If you want to call a file something specific just write it into your code.
Originally Posted by Beksters
$uploadFilename = 'yourFileName.jpg';
05-26-2012, 10:04 AM
Thanks for the response, but it's not quite what I meant. Sorry, I probably didn't explain it very well. I don't want to rename the file with the php code, I just want it to upload with exactly the same name it has when the user browses to it and selects it for upload, whatever that name will be. I don't wish to change that name, I just want the user to know what name to refer to when they enter <img src="...... .jpg" /> to add the image in a page.
Using your original method, which adds a long string of numbers before the image name, there is no way of knowing how to reference that image. I just want the user to be able to upload any files they wish and keep their original names. Is this possible?
05-26-2012, 10:06 AM
I forgot to mention that they won't be able to access the folder on the server to find the new file name, which is why it's such an issue to alter the name.
05-27-2012, 02:57 AM
Allowing people to decide the file name is a major security risk.
Originally Posted by Beksters
05-27-2012, 04:22 AM
It's okay, I just need to do this for a college project and the site won't go live so security is not going to be an issue in this case. I just need to be able to show that a user can upload an image to a folder and insert it into a page. The only way I can do it with the CMS I have is if the file name remains the same after upload so that the administrator can easily make a reference to it without having to access the files on the server. I'd really appreciate it if you could show me how to do this please? I won't be hand-coding any websites with PHP in the future, I'll use something like Wordpress or Joomla as I find PHP too complicated.
05-27-2012, 06:11 AM
Nothing complicated about PHP.
$uploadFilename = $_FILES[$fieldname]['name'];
05-27-2012, 07:08 AM
Thanks for your help, that works beautifully
06-14-2012, 05:09 AM
help with email notification
You are amazing and I have successfully set up using your codes etc but don' t know anything about coding with php.
When I receive the email notification I need the following details to be in the email
1. The name of the image the user uploaded - (with the renaming)
2. Preferably the url of the image
3. the details of the form that the person had filled out eg: name, address, email address etc. I'm sort of stuck in how to add those details to the actual html form so the php can read those fields
4. would also love to email the person automatically with confirmation
I really hope you can help me. I haven't changed the code at all, it's exactly as on the sticky so I won't bother posting it here. I have googled this question and read through all 22 pages but still not sure how to get what I need. thanks
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)