GaryLuck Posted February 27, 2009 Share Posted February 27, 2009 Hi there, I am having an issue with an move_upload_file statement. I am using smarty, however I don't think that is the cause, as I am doing all the uploading via php and using smarty to display the results. The process goes, I select a file, enter a name for it, and choose what album to add it to, (that part is done in mysql) then click upload. Untill I made an if statement to determine whether there was a problem, I did not know. And I do not seem to receive any errors either. Just no upload file. $directory = "imageuploads/"; $targetpath = $directory . basename($_FILES['photoFileName']['name']); $file = $_FILES['photoFileName']['name']; $ext = pathinfo($file, PATHINFO_EXTENSION); $allowedext = array ('jpg','gif','png','tif'); $maxfilesize = 10485760; if(!is_writable($directory)) { $uploadresult = "The directory ".$directory." is not writable"; } else { if(strlen($file) == 0) { $uploadresult = "No file was selected"; } else { if(!in_array($ext,$allowedext)) { $uploadresult = "Sorry, you cannot upload this filetype"; } else { if($file>=$maxfilesize) { $uploadresult = "Sorry, you're image is larger than the maximum file size."; } else { if (move_uploaded_file($file, $targetpath) == false) { $uploadresult = "Something went wrong.<br />"; $uploadresult1 = "The file, ".$file." did not upload"; $uploadresult2 = "Description:<br /><br />".$_POST['photoName'].""; print_r(error_get_last());; } else { $uploadresult = "The file ".$file." has been uploaded"; mysql_query("INSERT INTO photo values(NULL,'".$_POST['photoName']."','".$file."','".$_POST['albumId'].")"); } } } } } Any help would be much appreciated. Also please bear in mind that I am somewhat of a noob at this, so be gentle ;-). Thank you in advance! Link to comment https://forums.phpfreaks.com/topic/147205-solved-move_upload_file-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.