file upload not moving/copying

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jive
Forum Newbie
Posts: 20
Joined: Thu May 23, 2002 1:34 pm
Contact:

file upload not moving/copying

Post by jive »

Hello folks I have the following form:


Code: Select all

include ('connect.php');

$dbconnect = mysql_select_db('aircraftsales');

$actypelist = mysql_query('SELECT ID, type FROM ac_type');
<form name="addaircraft" method="post" action="<?=$_SERVER['PHP_SELF']?>"

enctype="multipart/form-data">

Add aircract to which aircraft type?:

<select name="typeID">

<option value="">Aircraft Type</option>

<option value="">- - - - - - - -</option>

Code: Select all

while($actype = mysql_fetch_array($actypelist)) {

$typeID = $actype['ID'];

$type = $actype['type'];

echo('<option value="' . $typeID . '">' . $type . "</option>\n" );

}
</select>

<br><br>

Aircraft Name: <input type="text" size="50" maxlength="100" name="ac_name">

<br>

Serial Number: <input type="text" size="50" maxlength="100" name="serial_num"><BR>

Registration Number: <input type="text" size="50" maxlength="100" name="registration_num"><BR>

Engines<BR>

Left:<input type="text" size="50" maxlength="100" name="L_engine"><BR>

Right:<input type="text" size="50" maxlength="100" name="R_engine"><BR>

Propellers<br>

Left:<input type="text" size="50" maxlength="100" name="L_propeller"><BR>

Right:<input type="text" size="50" maxlength="100" name="R_propeller"><BR>

Center:<input type="text" size="50" maxlength="100" name="C_propeller"><BR>

Interior:

<br>

<textarea cols="80" rows="10" name="interior"></textarea>

<script language="JavaScript1.2" defer>

editor_generate('topic_text');

</script>

<br><br>

Exterior<br>

<textarea cols="80" rows="10" name="exterior"></textarea><br>

Optional Equipment:<br>

<textarea cols="80" rows="10" name="optional_equip"></textarea><br>

Avionics:<br>

<textarea cols="80" rows="10" name="avionics"></textarea>

<br>

Exterior Image: <input type="file" name="img_exterior"> <br>

Cockpit Image: <input type="file" name="img_cockpit"> <br>

Interior Image: <input type="file" name="img_interior"> <br>





<input type="submit" value="submit" name="submit">

</form>


Code: Select all

if(isset($_POST['submit'])) {

$typeID = (int) $_POST['actype_ID'];

$ac_name = addslashes($_POST['ac_name']);

$serial_num = addslashes($_POST['serial_num']);

$registration_num = addslashes($_POST['registration_num']);

$L_engine = addslashes($_POST['L_engine']);

$R_engine = addslashes($_POST['R_engine']);

$L_propeller = addslashes($_POST['L_propeller']);

$R_propeller = addslashes($_POST['R_engine']);

$C_propeller = addslashes($_POST['registration_num']);

$interior = addslashes($_POST['interior']);

$exterior = addslashes($_POST['exterior']);

$optional_equip = addslashes($_POST['optional_equip']);

$avionics = addslashes($_POST['avionics']);

//confused somewhere here.    

if ($_FILES['img_exterior']['type'] == "image/gif" or $_FILES['img_exterior']['type'] == "image/pjpeg"){ 

move_uploaded_file($_FILES['img_exterior']['tmp_name'], "images/".$_FILES['img_exterior']['name']) 

    or die ("Could not copy"); }

else { 

 

            echo "Could Not Copy, Wrong Filetype (".$_FILES['img_exterior']['name'].")"; 

 

        } 

//} 

//interior upload

if ($_FILES['img_interior']['type'] == "image/gif" or $_FILES['img_interior']['type'] == "image/pjpeg"){ 

move_uploaded_file($_FILES['img_interior']['tmp_name'], "images/".$_FILES['img_interior']['name']) 

    or die ("Could not copy"); }

else { 

 

            echo "Could Not Copy, Wrong Filetype (".$_FILES['img_interior']['name'].")"; 

 

        } 

//} 

if ($_FILES['img_cockpit']['type'] == "image/gif" or $_FILES['img_cockpit']['type'] == "image/pjpeg"){ 

move_uploaded_file($_FILES['img_cockpit']['tmp_name'], "images/".$_FILES['cockpit']['name']) 

    or die ("Could not copy"); }

else { 

 

            echo "Could Not Copy, Wrong Filetype (".$_FILES['img_cockpit']['name'].")"; 

 

        } 

//} 

 

 

echo($ac_name);

$sql = 'INSERT INTO ac_description SET

        actype_ID = ''' . $typeID . ''',

        ac_name = ''' . $ac_name . ''',

        serial_num = ''' . $serial_num . ''',

registration_num = ''' . $registration_num . ''',

        L_engine = ''' . $L_engine . ''',

        R_engine = ''' . $R_engine . ''',

L_propeller = ''' . $L_propeller . ''',

        R_propeller = ''' . $R_propeller . ''',

C_propeller = ''' . $C_propeller . ''',

interior = ''' . $interior . ''',

        exterior = ''' . $exterior . ''',

optional_equip = ''' . $optional_equip . ''',

avionics = ''' . $avionics . ''',

img_exterior = ''' . $_REQUEST['img_exterior']['name'] . ''', 

        img_interior = ''' . $_REQUEST['img_interior']['name'] . ''',

img_cockpit = ''' . $_REQUEST['img_cockpit']['name'] . '''';

 

 

 

 

 

if (@mysql_query($sql)) {

    echo('The new aircraft has been added ');

} else {

    echo('could not add new aircraft:' . mysql_error());

}

}

The form and database is on my webserver and the images that I'm trying to upload are on my local machine.
I'm getting the following error when I submit the form info and upload the files:


Warning: move_uploaded_file(C:/Program Files/Apache Group/Apache/projects/ectaviation/acsales/images/photosample1.gif): failed to open stream: No such file or directory in /home/ectaviat/public_html/aircraftsales/newac_add.php on line 78



Warning: move_uploaded_file(): Unable to move '/tmp/php2r9wWG' to 'C:/Program Files/Apache Group/Apache/projects/ectaviation/acsales/images/photosample1.gif' in /home/ectaviat/public_html/aircraftsales/newac_add.php on line 78

Could not copy



can somebody help?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Is images/ already made? If so, do you have read/write access to it?
jive
Forum Newbie
Posts: 20
Joined: Thu May 23, 2002 1:34 pm
Contact:

Post by jive »

thats probably it. I didn't chmod the folder. I'm at work right now, I tell you if that works in a few...

btw,
thanks :lol:
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

np =)
jive
Forum Newbie
Posts: 20
Joined: Thu May 23, 2002 1:34 pm
Contact:

Post by jive »

well sami, that was part of the problem, but I've run into yet another issue. (surprise, surprise) :) on this thread:

viewtopic.php?p=71157#71157
Post Reply