Anz Posted April 8, 2013 Share Posted April 8, 2013 Hello PHPFreaks. First time here and ive been trying to check through the forums for some help. But i cant seem to figure it out.Whatever, lets get to the point. Im running a webpage for LAN events. And i have the feature that you can upload profile images. (but i have to accept these). And when im accepting them, it turns like this. Warning: rename(/user/user_bilder/1_1.jpg,1.jpg) [function.rename]: No such file or directory in /home/winglans/public_html/admin/acceptera_avatar.php on line 22 The code on line 22 is: rename('/user/user_bilder/'.$_GET['fil'].'', ''.$_GET['uid'].'.'.$format.''); The pictures should be saved at '/user/user_bilder/. Code closeby: if(isset($_GET['accept'])) { $query = mysql_query("delete from bild_upload where bID = '".$_GET['bid']."'"); $format = "jpg"; rename('/user/user_bilder/'.$_GET['fil'].'', ''.$_GET['uid'].'.'.$format.''); $laggTill = "INSERT INTO user_meddelande (`from_id`, `to_id`, `from_nick`, `to_nick`, `ip`, `date`, `tid`, `titel`, `meddelande`) VALUES ('".$_SESSION['lan_uid']."','".$_GET['uid']."','Bild accepterings system','".$_GET['user']."','".$_SERVER['REMOTE_ADDR']."','" .date("d/m-y"). "','" .date("H:i:s"). "','Bild accepterad/nekad','Din bild har blivit accepterad')"; mysql_query($laggTill) or die(mysql_error()); I got some more stuff ill probably be posting later, thanks for reading my thread and helping/trying. Best Regards Tobias Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/ Share on other sites More sharing options...
davidannis Posted April 8, 2013 Share Posted April 8, 2013 Looks like the OS can not find the file to rename. My guess is that the file is not in /user/user_bilder/ Look at the upload and see where the files are put before approval. Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423585 Share on other sites More sharing options...
Anz Posted April 8, 2013 Author Share Posted April 8, 2013 Looks like the OS can not find the file to rename. My guess is that the file is not in /user/user_bilder/ Look at the upload and see where the files are put before approval. Thanks for answering so quickly! Code from the upload file: (it may contain some swedish words) <?PHP if(isset($_GET['ladda_upp'])) { error_reporting(E_ALL); // Vilka filer skall få laddas upp? $ext = array(".jpg"); // Max storlek $max_file_size = "500000"; // Vart skall filerna laddas till? // behörighet krävs! $target_dir = "user/user_bilder/"; //Userid framför namnet $_FILES['userfile']['name'] = $_SESSION['lan_uid'] . '_' . str_replace(' ', '_', $_FILES['userfile']['name']); // Inga mellanslag $_FILES['userfile']['name'] = str_replace(' ', '_', $_FILES['userfile']['name']); $file_name = $_FILES['userfile']['name']; $file_name = strrchr($file_name, "."); if(!in_array($file_name,$ext)) { $error = "Du kan inte ladda upp en fil med det filformatet. Dom som stöds är "; foreach( $ext as $exts ){ $error .= "$exts "; } die ("$error"); } $file_size = $_FILES['userfile']['size']; if($file_size > $max_file_size) { die ("Filen är för stor, max storleken är ".$max_file_size." b"); } // Kolla att en fil är uppladdad och flytta den till målkatalogen if (isset($_POST['submit']) && is_uploaded_file($_FILES['userfile']['tmp_name'])) { move_uploaded_file($_FILES['userfile']['tmp_name'], $target_dir.$_FILES['userfile']['name']); // Här kan du lägga in lite data i en databas om du vill det, annars är det bara att // fortsätta med en Header location. } $file = $_FILES['userfile']['name']; $laggTill = "INSERT INTO bild_upload (`user`, `userid`, `fil`, `date`) VALUES ('".$_SESSION['lan_username']."', '".$_SESSION['lan_uid']."', '".$file."', '".date("y-m-d H:i:s")."')"; mysql_query($laggTill) or die(mysql_error()); mysql_close($connection); header("Location: ./??p=lan&sid=16&tack=7"); die(); } $hmm = mysql_query("SELECT * FROM bild_upload WHERE `userid` = '".$_SESSION['lan_uid']."'") or die(mysql_error()); $r = mysql_fetch_array($hmm); if ($r) { header("location: ./?p=lan&sid=15&tack=5"); die(); } $target_dir = "user_bilder/"; if (file_exists($target_dir.$_SESSION['lan_uid'].".jpg")) { header("location: ./?p=lan&sid=15&tack=6"); die(); } ?> <form enctype="multipart/form-data" action="./?p=lan&sid=45&ladda_upp=ja" method="post" style="text-align:left; width:265px; margin:10px auto; padding:10px"> <p><strong>Regler<br> </strong>Bilden får inte inehålla rasistiskt/pornografiskt inehåll.<br> Storleken ska vara ca 80*65px<br> Max 0.5mb stor.<br> jpg format.<br> <input type="hidden" name="MAX_FILE_SIZE" value="20000000"> <input name="userfile" type="file" style="width:100%"> <input type="submit" name="submit" value="Ladda upp" style="width:100px; margin:auto;"> </p> </form> Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423586 Share on other sites More sharing options...
Jessica Posted April 8, 2013 Share Posted April 8, 2013 rename('/user/user_bilder/'.$_GET['fil'].'', ''.$_GET['uid'].'.'.$format.''); Uhm, the error message shows you exactly what you did. You are looking for one file with a comma in it. Check your string concatenation. This function will take two arguments, not one. Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423587 Share on other sites More sharing options...
Anz Posted April 8, 2013 Author Share Posted April 8, 2013 rename('/user/user_bilder/'.$_GET['fil'].'', ''.$_GET['uid'].'.'.$format.''); Uhm, the error message shows you exactly what you did. You are looking for one file with a comma in it. Check your string concatenation. This function will take two arguments, not one. Im sorry if im not getting you right, something like this? rename('user/user_bilder/'.$_GET['fil'].'', 'user/user_bilder/'.$_GET['uid'].'.'.$format.''); Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423589 Share on other sites More sharing options...
Jessica Posted April 8, 2013 Share Posted April 8, 2013 That's better, but there's no reason for the random empty strings... Did you try it? Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423596 Share on other sites More sharing options...
Anz Posted April 8, 2013 Author Share Posted April 8, 2013 Strange, still the same error.. How would you do that code? And ill try yours. Thanks so far btw! Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423602 Share on other sites More sharing options...
Jessica Posted April 8, 2013 Share Posted April 8, 2013 The EXACT same error?? Save the file. Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423604 Share on other sites More sharing options...
Anz Posted April 9, 2013 Author Share Posted April 9, 2013 The EXACT same error?? Save the file. Yep :/ Warning: rename(user/user_bilder/1_,1.jpg,user/user_bilder/1.jpg) [function.rename]: No such file or directory in /home/winglans/public_html/admin/acceptera_avatar.php on line 22 Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423612 Share on other sites More sharing options...
davidannis Posted April 9, 2013 Share Posted April 9, 2013 Your new error message has a comma after the 1_ The old error message did not. Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423614 Share on other sites More sharing options...
jazzman1 Posted April 9, 2013 Share Posted April 9, 2013 The pictures should be saved at '/user/user_bilder/ The pictures should be saved in /user/user_bilder/ or user/user_bilder/ ? rename(user/user_bilder/1_,1.jpg,user/user_bilder/1.jpg) Quote Link to comment https://forums.phpfreaks.com/topic/276697-begginner-i-need-some-help/#findComment-1423615 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.