Mr Chris Posted February 8, 2007 Share Posted February 8, 2007 Hi all, I've created a form whereby I want to upload images and pass a story_id onto the next page (uploader.php) Now i've got it working so it passes the story_id, but the images don't longer upload and I get the message: There was an error uploading the file, please try again I can’t see what’s wrong though. Can anyone please help as i'm stumped as I think it should work? Thanks Chris upload.php <? if($_POST["x"] == "Upload"){ $story_id = $_POST['story_id']; header("Location: uploader.php?story_id=$story_id"); } ?> <form action="" method="post" enctype="multipart/form-data"> <input type='hidden' name='story_id' value='<?php echo $_GET['story_id'];?>' /> <input type='hidden' name='MAX_FILE_SIZE' value='25000000'> File 1: <input type='file' name='uploadedfile' size='30'></p> ;; <p> Video Credit: <INPUT TYPE="text" SIZE="48" MAXLENGTH="255" NAME="video_credit" <?php if(isset($video_credit)) echo "value='$video_credit'"; ?>/> // </p> <p>Video Caption: <INPUT TYPE="text" SIZE="48" MAXLENGTH="255" NAME="video_caption" <?php if(isset($video_caption)) echo "value='$video_caption'"; ?>/> <br> <br> <INPUT TYPE="submit" VALUE="Upload" NAME="x"> </p> <p> </p> </form> However, despite this the image now will not upload. uploader.php <?php $target_path = "video/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; // Start the connection to the database include('*********'); $can_i_connect = db_connect(); // by db_connect function is in my include file if(!$can_i_connect) { $msg = "Could not connect to the database"; } // End the connection to the database // insert into database $date_uploaded = date("m d, Y"); $directory = "video/"; $file_name = basename( $_FILES['uploadedfile']['name']); $video_caption = stripslashes(trim($_POST['video_caption'])); $video_credit = stripslashes(trim($_POST['video_credit'])); $story_id = $_GET['story_id']; $sql_query = mysql_query("INSERT INTO cms_videos (date_uploaded,directory,file_name,video_caption,video_credit,story_id) VALUES ('$date_uploaded','$directory','$file_name','$video_caption','$video_credit','$story_id')"); if (!$sql_query) { exit("<p>Error performing query: " . mysql_error() . "</p>"); } } else{ echo "There was an error uploading the file, please try again!"; } ?> Link to comment https://forums.phpfreaks.com/topic/37598-form-upload-can-someone-please-proof-read/ Share on other sites More sharing options...
JasonLewis Posted February 8, 2007 Share Posted February 8, 2007 in the move_uploaded_file change the tmp_name to just name. Link to comment https://forums.phpfreaks.com/topic/37598-form-upload-can-someone-please-proof-read/#findComment-179776 Share on other sites More sharing options...
Mr Chris Posted February 8, 2007 Author Share Posted February 8, 2007 Thanks, but it's not that. I thought you needed to assign the uploaded image a temporary filename anyway? Any other suggestions anyone? Thanks Chris Link to comment https://forums.phpfreaks.com/topic/37598-form-upload-can-someone-please-proof-read/#findComment-179781 Share on other sites More sharing options...
Mr Chris Posted February 8, 2007 Author Share Posted February 8, 2007 Anyone? Thanks Link to comment https://forums.phpfreaks.com/topic/37598-form-upload-can-someone-please-proof-read/#findComment-179906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.