logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 02-16-2014, 10:34 PM   #1
mnwuzor
 
Join Date: Feb 2014
Posts: 1
Question Error in image file upload using dreamweaver

Greeting to you all!

Please I need you PRO help. My case seem similar to some of the ones I have seen but my code is completely different.

I wrote this code below using PHP in Dreamweaver and its used to upload images to MySQl database. Now when I upload about 6 images, it shows File Uploaded Successfully. But if I try to upload any thing below 6 images, it will refuse to upload and will echo Upload Failed.

<?php
if(isset($_POST['submit']))
{
$projid=$_POST['projid'];
$projname=$_POST['projname'];

$name=basename($_FILES['file_upload']['name']);
$t_name=$_FILES['file_upload']['tmp_name'];
$dir='upload';
if(move_uploaded_file($t_name,$dir."/".$name))

$nameone=basename($_FILES['file_uploadone']['name']);
$t_name=$_FILES['file_uploadone']['tmp_name'];
$dir='upload1';
if(move_uploaded_file($t_name,$dir."/".$name))

$nametwo=basename($_FILES['file_uploadtwo']['name']);
$t_name=$_FILES['file_uploadtwo']['tmp_name'];
$dir='upload2';

if(move_uploaded_file($t_name,$dir."/".$name))
$namethree=basename($_FILES['file_uploadthree']['name']);
$t_name=$_FILES['file_uploadthree']['tmp_name'];
$dir='upload3';

if(move_uploaded_file($t_name,$dir."/".$name))
$namefour=basename($_FILES['file_uploadfour']['name']);
$t_name=$_FILES['file_uploadfour']['tmp_name'];
$dir='upload4';
if(move_uploaded_file($t_name,$dir."/".$name))

$namefive=basename($_FILES['file_uploadfive']['name']);
$t_name=$_FILES['file_uploadfive']['tmp_name'];
$dir='upload5';
if(move_uploaded_file($t_name,$dir."/".$name))
{
mysql_select_db ($database_ProjMonEva,$ProjMonEva);
$qur="insert into tbl_images (imageid, projid, projname, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) values ('','$projid','$projname','$name','upload/$name','$nameone','upload/$ nameone','$nametwo','upload/$nametwo','$namethree','upload/$namethree' ,'$namefour','upload/$namefour','$namefive','upload/$namefive')";
$res=mysql_query($qur,$ProjMonEva);
echo 'File uploaded successful';
}
else
{
echo 'upload failed!';
}
}
?>

I see the problem to come from the echo but I am stock and dont know how to correct it. Can any one please help me.

Thank you in advance Mike
mnwuzor is offline   Reply With Quote
Old 02-17-2014, 12:27 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

without getting to deeply into your code , as I dont have a lot of spare time at the moment, you should look at putting the file uploads into an if condition
if(!empty($_POST['upload2']) {

do stuff
}
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:15 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com