homepage Welcome to WebmasterWorld Guest from 107.20.25.215
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

    
Can't Upload & Chg image - PARSING PICTURE UPLOAD
Scotty13




msg:4440621
 7:50 pm on Apr 13, 2012 (gmt 0)

If its not one thing its another. Im a newbie just trying to build a social network website from some tutorials online.

When I try to change my picture, I get these errors…

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

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php7MzLn5' to 'members/6/image01.jpg' in /home/******/public_html/edit_res.php on line 70

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

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php7MzLn5' to 'members/6/image01.jpg' in /home/******/public_html/edit_res.php on line 95

(Lines 70 & 95 are marked below)

// ------- IF WE ARE PARSING ANY DATA -----------------------------------------------------

if (!isset($_POST['parse_var']))
{
$_POST['parse_var'] = "undefined";
}
if($_POST['parse_var'] == "undefined")
{
//Code to handle undefined exception
}

if ($_POST['parse_var'] == "pic"){
// If a file is posted with the form
if ( isset($_FILES['fileField']) && ! empty($_FILES['fileField']['tmp_name']) ) {
$maxfilesize = 2097152; // equal to 2 mb
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 70) $place_file = move_uploaded_file( $_FILES['fileField']['tmp_name'], "members/$id/".$newname);
}
}
}
// ------- 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 95) $place_file = move_uploaded_file( $_FILES['fileField']['tmp_name'], "members/$id/".$newname);
}
}
}
// ------- END PARSING PICTURE UPLOAD ---------


THANK YOU FOR YOUR HELP!
Scott

 

Scotty13




msg:4440624
 7:55 pm on Apr 13, 2012 (gmt 0)

FIXED IT! The entry is good, I missed a word that I had changed in other scripts and didnt see it on this sections.

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