MinusMyThoughts Posted November 3, 2006 Share Posted November 3, 2006 I'm using an older reference book to put together an image uploading page on my site, so the user can change the images displayed on their site. i'm not sure what i'm doing wrong, but my file type check is failing and killing the rest of my script, telling me that the file is in an unrecognized format......i'm uploading a small .jpg file to test with, so it shouldn't be causing an error......anyways, here's the code i'm using.my upload form <form enctype="multipart/form-data" action="picUpload.php" method=post target="_parent"> <input type="hidden" name="picID" value="pic1"> <input type="hidden" name="MAX_FILE_SIZE" value="1024000"> <input name="pic" type="file"> <input type="submit" value="Upload"> </form> my script to handle the upload <?php session_start(); $picID = $_POST['picID']; $pic_tmp = $_FILE['pic']['tmp_name']; $pic = $_FILE['pic']['name']; $pic_size = $_FILE['pic']['size']; $pic_type = $_FILE['pic']['type']; $pic_error = $_FILE['pic']['error']; $_SESSION['picID'] = $picID; $_SESSION['pic'] = $pic;//file upload check if ($userfile_error) { echo 'Problem: '; switch ($userfile_error) { case 1: echo 'File exceeded maximum filesize!'; break; case 2: echo 'File exceeded maximum filesize!'; break; case 3: echo 'File only partially uploaded!'; break; case 4: echo 'No file uploaded!'; break; } exit; } if ($pic_type != 'image') { echo 'Problem: The file you uploaded is not in a recognized format!'; exit; } $upfile = 'images/userPics/'.$picID; if(is_uploaded_file($userfile)) { if(!move_uploaded_file($userfile,$upfile)) { echo 'Problem: Could not move file to destination directory.'; exit; } } else { echo 'Error with the file you uploaded: '.$userfile_name; exit; }?><html>//my formatting HTML<?php echo 'File uploaded successfully!<br/><br/>'; echo '<img src="images/userPics/'.$picID.'"><br/><br/>'; echo '<a href="phat2575.php">Return to update page</a>';?></html><?php session_write_close();?> i'm not quite sure what i've done wrong, so any suggestions are greatly appreciated! thanks!love,jason Link to comment Share on other sites More sharing options...
MinusMyThoughts Posted November 3, 2006 Author Share Posted November 3, 2006 sorry. i found an updated online resource and solved my own problem. nevermind!love,jason Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now