1 Replies - 158 Views - Last Post: 24 June 2011 - 02:51 AM Rate Topic: -----

#1 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Uploading system

Posted 24 June 2011 - 01:45 AM

I'm getting this error:

Quote

Warning: move_uploaded_file(files/good 2v2 ppvspt.rep) [function.move-uploaded-file]: failed to open stream: No such file or directory in /hermes/web04/b2008/moo.battlesccom/mediaupload.php on line 96

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpLGBkge' to 'files/good 2v2 ppvspt.rep' in /hermes/web04/b2008/moo.battlesccom/mediaupload.php on line 96



<?php
if(isset($_POST['btnSend'])){
$num = count($_FILES['upload']['name']) - 1;
for($i=0;$i<$num;$i++){
	$name = $_FILES['upload']['name'][$i];
	$tmp  = $_FILES['upload']['tmp_name'][$i];
	$path = "files/$name";
	if(!move_uploaded_file($tmp,$path)){
		echo "<p style='color:red'>File: $name not uploaded</p>";
	}else{
	echo "<p style='color:green'>File: $name uploaded<br /></p>";
	}
}
}
?>
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript'>
function add(){
	$(document).ready(function(){
		$("#lbl").before("<input type='file' name='upload[]' id='upload[]' onchange='add()' /><br />");
	});
}
window.load(add());
</script>

<form id='frmUploadFiles' name='frmUploadFiles' action='<?PHP echo $_SERVER['PHP_SELF'];?>' method='post' enctype="multipart/form-data">
<label id='lbl'></label>
<button type='submit' id='btnSend' name='btnSend' onclick='x()'>Upload</button>
</form>


Is This A Good Question/Topic? 0
  • +

Replies To: Uploading system

#2 youngone  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 60
  • Joined: 12-June 11

Re: Uploading system

Posted 24 June 2011 - 02:51 AM

I would recommend renaming your directory name to a name without spaces. Also check relative/absolute paths. There is a difference between files/ and /files/. Put this code in the header of your upload PHP script to check whether you are working with the directory you really want to work with:
echo is_dir("files/") ? "exists" : "doesnt exist";


When you get a message that the directory exists, use the path in your upload script. It really depends on your directory hiearchy. Cannot help much more now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1