Jump to content

Begginner - I need some help


Anz

Recommended Posts

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.'');
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.