/    Sign up×
Community /Pin to ProfileBookmark

Recording path on MYSQL

Hi,

And thank you for any help.

My script take a name from the DB (“ID” +1) and with this number create a folder after that he will upload and send the pictures selected by the user to this folder after that he will record the path to this picture on MYSQL.

Now the script can upload the pictures and record the path but he can’t do both at the same time. I isolate the problem and if we use this name=”file[0]” on the script we can upload the picture with out problems and if we use name=”file0″ we can record the path. I hope someone can help me to modify the script on a way that he can upload/record the path at the same time.

[color=Blue] Here is the 4 places where we need make the changes name=”file0″ / name=”file[0]” and at the end of this post you can download all the script by clicking the link[/color]

[b]lines 152[/b]

[code=php]
<!– change/cambiar this name=”file[0]” by name=”file0″ –>
<input class=”file” type=”file” name=”file0″ />[/code]

[b]line 245[/b]

[code=php]
<!– change/cambiar this name=”file[0]” by name=”file0″ –>
<input class=”file” type=”file” name=”file0″ />[/code]

[b]line 273[/b]

[code=php]
<!– change/cambiar this name=”file[0]” by name=”file0″ –>
<input class=”file” type=”file” name=”file0″ />[/code]

[b]line 282[/b]

[code=php]
<!– change/cambiar this name=”file[0]” by name=”file0″ –>
<input class=”file” type=”file” name=”file0″ />[/code]

[color=Blue] [size=5] “The CODE” [/size] [/color]
by clicking here you can download the code: [url=http://www.megaupload.com/?d=01MICDFH]http://www.megaupload.com/?d=01MICDFH[/url]

The uploading function

[code=php] <?
}

function upload_file ($upload_path, $fname, $fileid)
{
$problem = TRUE;

switch ($_FILES[‘file’][‘error’][$fileid])
{
case UPLOAD_ERR_FORM_SIZE:
$error = “The uploaded file exceeds the 85kb”;
break;
case UPLOAD_ERR_NO_FILE:
$error = “No file was uploaded”;
break;
default:
$error = “”;
}

//test
$fname = $_FILES[‘file’][‘name’][$fileid];
$dest = $upload_path.$fname;
$tmpfile = $_FILES[‘file’][‘tmp_name’][$fileid];

if ($tmpfile)
{
$info = getimagesize($tmpfile);
$ftype = $info[‘mime’];

if ($ftype != “image/gif” && $ftype != “image/jpeg”)
{
$error = “File type not supported”;
$problem = TRUE;
}
else
{
if (file_exists($dest))
{
$error = “File already exists. (“.$dest.”)”;
$problem = TRUE;
}
else
{
copy ($tmpfile,$dest);
$problem = FALSE;
}
}
}

return array($problem, $error);
}
?>
[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@_LOBO_authorJun 17.2005 — *bump*
Copy linkTweet thisAlerts:
@bokehJun 17.2005 — you can't do that. If you are uploading multiple files you either need to give them unique names in the form eg:

file1

file 2

file 3

or if you want each form input identical you would need:

file[]

file[]

file[]

Also have you thought about storing the file directly in the MySql database instead of in a directory?
Copy linkTweet thisAlerts:
@_LOBO_authorJun 17.2005 — Thanx for trying to help me ?

ok what I need to do is upload diferent files (images jpeg/gif) to the same folder for this Im using this kind of imput and recording the path to those files on mysql ('".$_POST['file0']."',)
[code=php]
<input class="file" type="file" name="file0" />
<br />
1:
<input class="file" type="file" name="file[1]" />
<br />
2:
<input class="file" type="file" name="file[2]" />
<br />
3:
<input class="file" type="file" name="file[3]" />
<br />
4:
<input class="file" type="file" name="file[4]" />
<br />
5:
<input class="file" type="file" name="file[5]" />
<br />
6:
<input class="file" type="file" name="file[6]" />
<br />
7:
<input class="file" type="file" name="file[7]" />
<br />
8:
<input class="file" type="file" name="file[8]" />
<br />
9:
<input class="file" type="file" name="file[9]" />
<br />
<input name="Submit" type="submit" id="Submit" value="Submit Images" />
[/code]

you can't do that. If you are uploading multiple files you either need to give them unique names in the form eg:

file1

file 2

file 3

or if you want each form input identical you would need:

file[]

file[]

file[]

Also have you thought about storing the file directly in the MySql database instead of in a directory?[/QUOTE]
Copy linkTweet thisAlerts:
@bokehJun 17.2005 — Im using this kind of imput and recording the path to those files on mysql ('".$_POST['file0']."',)[/QUOTE]

Shouldn't you be using $_
FILES?
×

Success!

Help @_LOBO_ spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...