homepage Welcome to WebmasterWorld Guest from 54.237.98.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Warning: move uploaded file
Scotty13



 
Msg#: 4486587 posted 9:07 pm on Aug 20, 2012 (gmt 0)

In my web page I want members to be able to change there image/picture. Below are to sep. codes in edit_res.php

Error on line 83, itís marked below.

_____________________________________________________

<form action="edit_res.php?id=<?php echo $id; ?>" method="post" enctype="multipart/form-data">
<tr>
<td width="61"><?php echo $user_pic; ?></td>

<td width="521"><input name="fileField" type="file" class="formFields" id="fileField" size="42" />

50 kb max </td>
<td width="56"><input name="updateBtn1" type="submit" id="updateBtn1" value="Update" />
<input name="parse_var" type="hidden" value="pic" />
<input name="thisWipit" type="hidden" value="<?php echo $thisRandNum; ?>" />
</td>
</tr>
</form>
</table>
_________________________________________________________

// ------- PARSING PICTURE UPLOAD ---------
if ($_POST['parse_var'] == "pic"){

// If a file is posted with the form
if ($_FILES['fileField']['tmp_name'] != "") {
$maxfilesize = 51200; // 51200 bytes equals 50kb
if($_FILES['fileField']['size'] > $maxfilesize ) {

$error_msg = '<font color="#FF0000">ERROR: Your image was too large, please try again.</font>';
unlink($_FILES['fileField']['tmp_name']);

} else if (!preg_match("/\.(gif|jpg|png)$/i", $_FILES['fileField']['name'] ) ) {

$error_msg = '<font color="#FF0000">ERROR: Your image was not one of the accepted formats, please try again.</font>';
unlink($_FILES['fileField']['tmp_name']);

} else {
$newname = "image01.jpg";
LINE 83: move_uploaded_file( $_FILES['fileField']['tmp_name'], "tktedmembers/$id/".$newname);
}
}
}

ERROR: When I try to test in browser.

Warning: move_uploaded_file(tktedmembers/33/image01.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/*******/edit_res.php on line 83



Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php1fgE1Z' to 'tktedmembers/33/image01.jpg' in /home/********/edit_res.php on line 83


Thanks,
Scotty13

 

ergophobe

WebmasterWorld Administrator ergophobe us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4486587 posted 10:46 pm on Aug 20, 2012 (gmt 0)

You're not telling it which $_FILES['fileField']['tmp_name'] to use. You'll need an array key like

$_FILES['fileField']['tmp_name'][0]

[php.net...]

Scotty13



 
Msg#: 4486587 posted 12:55 pm on Aug 23, 2012 (gmt 0)

I added [0] and NO ERROR, but still didnt change the image.

Scotty13



 
Msg#: 4486587 posted 12:59 pm on Aug 23, 2012 (gmt 0)

Permission is set at 755 (folder and image).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved